10-14-2021
06:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-14-2021
06:26 AM
Here is a version of that same rule that will dig down through all levels under the purchased sub assemblies to set them all to Purchased, just in case that is what you really wanted.
Sub Main()
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
oOccs = oAsmDoc.ComponentDefinition.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
'If it's not an Assembly, don't process it
If oOcc.DefinitionDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Continue For
'If it's not Purchased, don't process it
If oOcc.BOMStructure <> BOMStructureEnum.kPurchasedBOMStructure Then Continue For
StepDown(oOcc.Definition.Occurrences)
Next
End Sub
Sub StepDown(oComps As ComponentOccurrences)
For Each oComp As ComponentOccurrence In oComps
If oComp.BOMStructure <> BOMStructureEnum.kPurchasedBOMStructure Then
oComp.BOMStructure =BOMStructureEnum.kPurchasedBOMStructure
End If
If oComp.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
StepDown(oComp.Definition.Occurrences)
End If
Next
End Sub
Wesley Crihfield
(Not an Autodesk Employee)