AnsweredAssumed Answered

GetVar from Standalone Application not working - C#

Question asked by Sean Donnelly on Jun 22, 2017
Latest reply on Jun 23, 2017 by Michael Dekoning

Hello,

I posted a few weeks ago and am still having the same issue. I have a snippet of the code below, written in c#. The variable I am trying to retrieve is not blank and it is a version free variable. I get the error "Object reference not set to an instance of an object." when it tries to display the variable value. I know it is reading aFile because I call in my code (before this snippet) to show me the path, ID, etc. So it definitely knows it exists. Do I need to "Get" the file or something? or use EdmSelItem or something? What am I doing wrong here? I get this issue when I try to use the example on the website as well.

 

Edit: I am able to set the variable, so everything is correct to find the file. I just need to tweak something for getting the variable. Every time I call the object and to .tostring() it gives me the error.

Also, if I convert it the following way, it only gives me a blank value: string var = Convert.ToString(DwgVar);

 

My file is found via search. As I said, I am able to pull all local information from it.

I have the other variables defined as follows:

 

IEdmVault7 vault2 = null;
IEdmFile5 aFile;
IEdmFolder5 aFolder;
aFile = vault1.GetFileFromPath(Result.Path, out aFolder);
object DwgVar = null;

 

Here is the snippet of code:

IEdmEnumeratorVariable10 myvars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
            myvars = (IEdmEnumeratorVariable10)aFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  
            object DwgVar = null;
            myvars.GetVar("ITEM_DrawingNumber", "", out DwgVar);
            MessageBox.Show(DwgVar.ToString());

Outcomes