- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am struggling how to use commandmanager on all non referenced parts (BOM structure) of an assembly.
I want to open all parts of an assembly and do an "operation" with commandmanager, but only on those parts that are not set to reference (in the assembly BOM structure) and also their iproperty "part number" should start with "AAA".
The "operation" with commandmanager is to activate a third party add-inn on the specific part, but that just as an information why I want to open the parts.
My problem is checking the "If" condition about the BOM structure. (in line 11). I am doing it wrong. I am obviously checking the "BOM structure" of the part itself and not which "BOM structure" (default, not set to reference) the part has in the assembly.
Can anybody give me an advice how to improve my code?
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
Dim partnumber As String = oRefDoc.PropertySets(3)("Part Number").Value
If Left(partnumber, 3) = "AAA" And
oRefDoc.ComponentDefinition.Bomstructure = BOMStructureEnum.kDefaultBOMStructure Then
oPartPath = oRefDoc.FullFileName
' Open the target part
ThisApplication.Documents.Open(oPartPath)
oRefDoc.Activate
Call ThisApplication.CommandManager.ControlDefinitions.Item("3rd_party_add-inn").Execute
oRefDoc.Close
End If
Next
End Sub
Solved! Go to Solution.