02-10-2024
01:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-10-2024
01:58 PM
Rule to Open Drawing of every part in Assembly
Hi.
I have written rules to open drawings based on the BOM before, but now I am using vault I am trying to use
ThisApplication.CommandManager.ControlDefinitions.Item("VaultOpenDesignDocFromVault").Execute
I know to get this to work I need to select an Occurrence first, so I am using
ThisApplication.CommandManager.DoSelect(oOcc)
But my rule just keeps opening the same drawing over and over. Do I need to clear the selection somehow?
Here is the code in question:
For i =1 To oBOMRows.Count BOMItem = oBOMView.BOMRows.Item(i) oCompDef = BOMItem.ComponentDefinitions.Item(1) 'If oCompDef.BOMStructure <> 51972 Then If oCompDef.BOMStructure <> 51973 Then PartNum = oCompDef.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value VenNum = oCompDef.Document.PropertySets.Item("Design Tracking Properties").Item("Vendor").Value DesNum = oCompDef.Document.PropertySets.Item("Design Tracking Properties").Item("Description").Value 'PartNum = oCompDef.Document.PropertySets.Item(4).Item(2).Value Dim LongName As String = PartNum & " " & DesNum Try MsgBox(PartNum) oOcc = Component.InventorComponent(PartNum & ":1") 'MsgBox("Got Occurence of " & PartNum) CurrentDocName = oCompDef.Document.FullFileName ThisApplication.CommandManager.DoSelect(oOcc) ThisApplication.CommandManager.ControlDefinitions.Item("VaultOpenDesignDocFromVault").Execute Catch Msgbox("Failed to get" & PartNum) End Try Else 'do nothing End If Try DrawDoc = ThisApplication.ActiveDocument DrawName = DrawDoc.FullFileName DrawDoc.Close Catch End Try Next
Thanks to anyone who can help