how to i go down in a subassambly with Ilogic

how to i go down in a subassambly with Ilogic

Darkforce_the_ilogic_guy
Advisor Advisor
500 Views
5 Replies
Message 1 of 6

how to i go down in a subassambly with Ilogic

Darkforce_the_ilogic_guy
Advisor
Advisor

I have make a few code for doing stuff with illogic ... on part or assembly  but only at the first level

 

 

how word I get my Ilogic code to go look into all part and subassembly  all the way down the Assably structor?

 

and is there a way to look into the custom properties ?

 

And what about the file path ?

 

 

0 Likes
501 Views
5 Replies
Replies (5)
Message 2 of 6

JamieVJohnson2
Collaborator
Collaborator

Assemblies have Definitions (AssemblyComponentDefinition) have a list of occurrences (think of each node in the browser tree).

Each Occurrence has a list of SubOccurrences (if assembly file based) OR

Each Occurrence has a Document reference, where you can get its Definition (and start a new dive from that file being the top).

So Occurrences = tree with grounded root

SubOccurrences = branch of tree.

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 6

hozz__
Enthusiast
Enthusiast

I push parameter values down through an assembly like this...

 

Public Sub Main()

      'Assume that we won't be overriding the material right at the top level

      'so recurse down through the subassembly/part hierarchy

      'when drawer assembly Or_PanelMat True stop looking; when parameter does not exists children rule fails, cannot find parameter in children

      'when Or_PanelMat exists in all components rule runs as expected

      Call HandleSubAssemblies(ThisDoc.Document.ComponentDefinition.Occurrences)

End Sub

 

Public Sub HandleSubAssemblies(ByVal oOccurrences As ComponentOccurrences)

      'Called recursively for each assembly level

    Dim compo As ComponentOccurrence

    Dim MatThick As String

       

    For Each compo In oOccurrences

       

        If compo.DefinitionDocumentType = kAssemblyDocumentObject Then

                  'This is an assembly document so we want to go down to the next level

                  'unless it is marked as override material in which case we want to stop going

                  'down at this point

                  If Parameter(compo.Name,"Or_PanelMat") = False Then

                        'call this method recursively to go to a lower level

                  Call HandleSubAssemblies(compo.SubOccurrences)

                  End If

        ElseIf compo.DefinitionDocumentType = kPartDocumentObject Then

                  'This is a part so if we aren't overriding the panel material

                  'for this part then we'll figure out the required material

                  '***********************************************************************

                  '*** NOTE : if override material for the immediate parent assembly is true

                  '*** then we'll never get here

                  '***********************************************************************

                  If Parameter(compo.Name,"Or_PanelMat") = False Then

                        If Len(iProperties.Value(compo.Name, "Custom", "MThick")) > 6 Then

                              MatThick = Left(iProperties.Value(compo.Name, "Custom", "MThick"),

                                    iProperties.Value(compo.Name, "Custom", "PanelMat") = "PartVis"

                        End If

                  End If

        End If

    Next

End Sub

0 Likes
Message 4 of 6

JamieVJohnson2
Collaborator
Collaborator

Your logic looks good to me.  Is this issue done, or did I miss the point, or is there another point to work out?

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 5 of 6

hozz__
Enthusiast
Enthusiast
It wasn't my thread, so I'm not sure...I was just posting a block of code that I have that answered the question
0 Likes
Message 6 of 6

JamieVJohnson2
Collaborator
Collaborator

That's cool, for forum protocol, mark your posted code as the answer, so the next person researching your problem will know that's how you solved it.

 

Until next time,

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes