i found a bug in the code (in the first line). It should be fixed in the code below.
Dim doc As Document = ThisDoc.Document
Dim partslist As PartsList
Dim aDoc As AssemblyDocument
If (doc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject) Then
Dim dDoc As DrawingDocument = ThisDoc.Document
partslist = dDoc.ActiveSheet.PartsLists.Item(1)
aDoc = partslist.ReferencedDocumentDescriptor.ReferencedDocument
Else
aDoc = doc
End If
Dim BOM As BOM = aDoc.ComponentDefinition.BOM
BOM.StructuredViewEnabled = True
Dim oBOMView As BOMView = BOM.BOMViews("Structured")
oBOMView.Sort("BOM Structure", True, "Vendor", False)
oBOMView.Renumber(1, 1)
If (doc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject) Then
partslist.Sort("POS")
End If
about your second question. I would have been better if you started a new topic for that. So other people can find a solution more easy. but any way this is how you could do it.
Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim view As DrawingView = sheet.DrawingViews.Item(1)
Dim refDoc As Document = view.ReferencedDocumentDescriptor.ReferencedDocument
Dim category As String = iProperties.Value(refDoc.DisplayName ,"Summary", "Category")
If (String.IsNullOrWhiteSpace(category)) Then
Dim newCategory = InputBox("What is the category", "Title here", "Default Entry")
iProperties.Value(refDoc.DisplayName ,"Summary", "Category") = newCategory
End If
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com