I am trying to get list of all the variables from an assembly to read their values and update them if required. But strangely,
oVars = (SolidEdgeFramework.Variables)oAsm.Variables
is not returning complete collection of variables. e.g. if there are 119 variables in an assembly, it is returning only 72 variables. This is causing lot of issues while updating the assembly.
Am I missing anythig here? Please advice.
Solved! Go to Solution.
The other 47 elements are variables or are they dimensions? Solid edge has diferent object collection for variables and dimensions.
In variables table there are two types of objects:
Variables that appear as Var.
Dimensions that appear as Dim.
If they appear as Dim in the Variables Table, they are probably in the active document Relations3D collection (SolidEdgeAssembly.Realations3D) as SolidEdgeFrameworkSupport.Dimension objects.
Hope it helps.
Héctor Pelayo Izquierdo
Engineering Department, JAE Ingeniería y Desarrollos, S.L.
Solid Edge ST9 MP5 | NX 9
Thanks for the reply.
The missing elements are consisting of both Var and Dim variables. I have attahced a spreadsheet showing variables collection from API in 'VariablesList' sheet and list of variables from SolidEdge in 'SEVariables'.
As you can notice only 43 out of 143 variables are in Variables collection in this case.
as Hector said, Variables have two origins: Dimension elements and true Variable elements, these are two different object classes.
The Items from the Variables object only return the Variable elements. To get also the Dimension element use the Query() method. It has some parameters to filter the returned elements:
Option Strict On Imports SEFramework = SolidEdgeFramework ... Dim PartVariables As SEFramework.Variables = Nothing Dim VarList As SEFramework.VariableList = Nothing PartVariables = DirectCast(objDoc.Variables, SEFramework.Variables) '==== query all dimensions and variables VarList = DirectCast(PartVariables.Query("*", Nothing, SEConstants.VariableVarType.SeVariableVarTypeBoth, False), SEFramework.VariableList) ' filter the list by Type Dimension Dim Dims = VarList.OfType(Of SEFrameworkSupport.Dimension)() ' filter the list by Type variable Dim Vars = VarList.OfType(Of SEFramework.variable)()
I use the SeVariableVarTypeBoth option to return all elements and filter different types in two sets. Each set (dims or vars) can be looped like this:
For Each d As SEFrameworkSupport.Dimension In Dims ' do soumething