- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey there.
I have this code that pushes custom iproperties from the top level assembly down to all parts at all levels. I want to modify it so that it skips parts in the first layer of the assembly. For example:
- Top level assembly
- Subassembly (process)
- Part (process)
- Part (process)
- Part (skip)
- Subassembly (process)
- Subassembly (process)
- Part (process)
- Part (skip)
- Subassembly (process)
I tried inserting an "If" statement that checks whether the "oOcc" Occurrence is an assembly (kAssemblyDocumentObject) before executing the TraverseAssembly Public Subroutine, But I can't find a solution that works. I'm still learning iLogic so I tried feeding the problem to ChatGPT and it was unsuccessful. Could somebody spare a few minutes to look at this? Thank you so much.
Sub Main
'Gets the Active Document
oDoc = ThisDoc.Document
'Checks if the active document is an assembly
If oDoc.DocumentType = kAssemblyDocumentObject
'Gets the assembly occurrences
Dim oOccs As ComponentOccurrences
oOccs = oDoc.ComponentDefinition.Occurrences
'Call the subprocedure to traverse the assembly
Call TraverseAssembly(oOccs)
End If
End Sub
'***************
Public Sub TraverseAssembly(oOccs As ComponentOccurrences)
'Integer to traverse the assembly occurrences
Dim i As Integer
'For i=1 To oOccs.Count
Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
'oOcc = oOccs.Item(i)
If oOcc.Suppressed = False
'Occurrence Name (Display Name)
oOccName = oOcc.Name
Try
iProperties.Value(oOccName, "Custom", "extrusionColourCode") = iProperties.Value("Custom", "extrusionColourCode")
iProperties.Value(oOccName, "Custom", "extrusionColourName Date") = iProperties.Value("Custom", "extrusionColourName")
iProperties.Value(oOccName, "Custom", "panelClass") = iProperties.Value("Custom", "panelClass")
iProperties.Value(oOccName, "Custom", "panelType") = iProperties.Value("Custom", "panelType")
iProperties.Value(oOccName, "Custom", "rivetColourCode") = iProperties.Value("Custom", "rivetColourCode")
iProperties.Value(oOccName, "Custom", "rivetColourName") = iProperties.Value("Custom", "rivetColourName")
iProperties.Value(oOccName, "Custom", "sheetColourCode") = iProperties.Value("Custom", "sheetColourCode")
iProperties.Value(oOccName, "Custom", "sheetColourName") = iProperties.Value("Custom", "sheetColourName")
iProperties.Value(oOccName, "Custom", "sheetStockSize") = iProperties.Value("Custom", "sheetStockSize")
iProperties.Value(oOccName, "Custom", "sheetSupplier") = iProperties.Value("Custom", "sheetSupplier")
iProperties.Value(oOccName, "Custom", "zoneID") = iProperties.Value("Custom", "zoneID")
iProperties.Value(oOccName, "Custom", "elevation") = iProperties.Value("Custom", "elevation")
Catch
'It won't be able to change Read-Only parts (e.g. Content Center)
'MessageBox.Show("This is a content center file: " & oOcc.Name, "Title")
End Try
End If
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject
Call TraverseAssembly(oOcc.SubOccurrences)
End If
Next
End Sub
Solved! Go to Solution.
Link copied