Hello. I'm trying to make a rule that automatically places drawing views of my assembly. I figured using the BOM would be best since it gives the number of parts, the purchased parts, etc. I originally exported the BOM to an excel file and referenced that in my drawing rule. I'm trying to cut that step out.
I was wondering if there was an easy way to open files from the BOM. I tried adding "Filename" and "File Path" coulombs, but I couldn't get those to work outside of the excel file. Possibly because they're read only? Sorry if this is a dumb question, but I can't find a solution.
Attached testing code:
Dim modelDoc = ThisDrawing.ModelDocument Dim oBOM As BOM oBOM = modelDoc.ComponentDefinition.BOM Dim oBOMView As BOMView oBOMView = oBOM.BOMViews.Item("Parts Only") Dim i As Long For i = 1 To oBOMView.BOMRows.Count Dim oRow As BOMRow oRow = oBOMView.BOMRows.Item(i) Dim oCompDef As ComponentDefinition oCompDef = oRow.ComponentDefinitions.Item(1) Dim oPropSet As PropertySet oPropSet = oCompDef.Document.PropertySets.Item("Design Tracking Properties") MessageBox.Show(oPropSet.Item("Filename").Value, "Title") '<<<<<<<<<<<<<<<<<< problems ThisApplication.Documents.Open(oPropSet.Item("Filename").Value) '<<<<<<<<<<<<<<<<<< Next
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
I would suggest having this moved over to the ilogic forum if you need more help with this. Below you can retrieve the document from the definition and then the full file path. You could also just navigate through the referenced documents of the assembly. If you let us know the full workflow your planning you should be able to eliminate the export to excel and work directly in the assemblies/drawings.
Dim modelDoc = ThisDrawing.ModelDocument Dim oBOM As BOM oBOM = modelDoc.ComponentDefinition.BOM Dim oBOMView As BOMView oBOMView = oBOM.BOMViews.Item("Parts Only") Dim i As Long For i = 1 To oBOMView.BOMRows.Count Dim oRow As BOMRow oRow = oBOMView.BOMRows.Item(i) Dim oCompDef As ComponentDefinition oCompDef = oRow.ComponentDefinitions.Item(1)
Dim oDoc as Document = oCompDef.Document
Dim Fullfilename As String = oDoc.FullFileName
Dim oPropSet As PropertySet oPropSet = oCompDef.Document.PropertySets.Item("Design Tracking Properties")
If oPropSet.Item("PartNumber").Value = " Enter part Number here" Then
ThisApplication.Documents.Open(Fullfilename,True) '<<<<<<<<<<<<<<<<<< Next
End If
Can't find what you're looking for? Ask the community or share your knowledge.