Reply

Newbie question

[ Edited ]

 

Hi all

Newbie to SolidEdge and Cad programs but experienced programmer. This is probably a simple question but I'm stuck. Using C#, and I create a new instance of SE by code.

This code snippet gives me all variable names but how do I get the current values?

.....

                doc = (SolidEdgeAssembly.AssemblyDocument)application.ActiveDocument;

                variables = (SolidEdgeFramework.Variables)doc.Variables;

                variableList = (SolidEdgeFramework.VariableList)variables.Query("*", null, null, false);               

                for (int i = 1; i

                {                   

                    oVariable = variableList.Item(i);

                    MessageBox.Show(variables.GetName(oVariable));                           

                }

            }

            catch (Exception ex)

            {

....

Regards

Kjell-åke

 

 

Posted by: Kjell-Ake Boberg
Post date: 8/26/2009 2:44:34 AM

3 REPLIES

RE: Newbie question

[ Edited ]

Hi,

 

try with:

MessageBox.Show(oVariable.Value)

 

Regards

JR

 

Posted by: JR
Post date: 8/27/2009 3:13:35 AM

RE: Newbie question

[ Edited ]

 

Posted By JR on 08/27/2009 8:13 AM

Hi,

 

try with:

MessageBox.Show(oVariable.Value)

 

Regards

JR

Mmm.... not working I'm afraid. I have tried MessageBox.Show(oVariable.ToString()) but that gives the text "System.__comobj". Should be a quite common task but I'm stuck. When setting a value you can use variables.Edit("VarName","123") but I can't find a way to just read the value.

As the oVariable is declared as an "object" there might be necessary to do a typecast in order to read the value but I don't know which type to cast to.

Regards

Kjell-Åke

 

 

 

Posted by: Kjell-Ake Boberg
Post date: 8/27/2009 5:23:43 AM

RE: Newbie question

[ Edited ]

try with this declarations:

SolidEdgeFramework.variable oVariable = null;

string val;

 

and later with:

...

oVariable = (SolidEdgeFramework.variable)variableList.Item(i);

MessageBox.Show(variables.GetName(oVariable));

 

oVariable.GetValue(out val);

MessageBox.Show(val);

 

Posted by: JR
Post date: 8/27/2009 11:19:14 PM