Reply

Iterate trough SE assembly tree

[ Edited ]

Hello to all.

 

I'm new to SE programing and for this I need some guidence, with documentation or anything that helps.

 

I want to be able to iterate trough Solid Edge assembly, each tree component (part, sheet metal, subassembly) and read the parameters from those components and print the value of a parameter that I'm searching for.

 

I'm aware that is a lot of work but for the begining I'm interested on how can I iterate the entire tree of an assembly because I don't know from where to start and what to read related to this iteration subject.

 

Thank you in advance.

3 REPLIES

Re: Iterate trough SE assembly tree

Hi starlays
You can find a lot examples here:
https://github.com/SolidEdgeCommunity/Samples/tree/master/Assembly
(Thank you Jason!)
regards

JB
VS2015, SE ST10

Re: Iterate trough SE assembly tree

Thank you for the link.

 

I have managed to iterate the tree items and now I'm trying to read the variables from each sub-assembly, part or sheet metal.

 

First I'm trying to read the variables for the current active document and I'm getting an error and I don't know why.

 

I have tried this:

Dim oDoc As SolidEdgeDocument = oApp.ActiveDocument
Dim oVars As Variables = oDoc.Variables
Dim oVarlist As VariableList = oVars.Query("*")

For Each oVar As variable In oVarlist
   ' code here
Next oVar

I get an error at oVarlist in the foreach:

 

Why do I get this error?

Thank you in advance.

 

Re: Iterate trough SE assembly tree

Hi starlays,

the reason is, that the Query return Variable and Dimension objects.

Again, there are examples on Github or look in the SDK help ("Working with the Variable Table")

You have two possibilities:

1) change the Query to return only Dimensions or Variables using the VarType parameter

2) using oVar as Object and handle the two cases in the loop

 

Regards JB

regards

JB
VS2015, SE ST10