10-22-2023
02:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
10-22-2023
02:34 AM
This code is for the part more interesting. The Part List comes with both number part and quantity.
This code is for the part more interesting. The Part List comes with both number part and quantity.
Sub Main
Dim invDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = invDoc.ActiveSheet
Dim oSheet1 As Sheet = invDoc.Sheets.Item(1)
Dim oDrawingView As DrawingView = oSheet1.DrawingViews(1)
Dim oBorder As Border = oSheet.Border
Dim oPlacementPoint As Point2d
If Not oBorder Is Nothing Then
oPlacementPoint = oBorder.RangeBox.MaxPoint
Else
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height) 'Kur ideti partlista
End If
Dim partsListBomType As PartsListLevelEnum = 46593
Dim oPartsList_G As PartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, partsListBomType)
For Each oRow In oPartsList_G.PartsListRows
oRow.Visible = True
Next
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "pick drawing view.")
Dim oSheet2 As Sheet = oView.Parent
Dim RefDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim RefDocName As String = RefDoc.FullFileName
Dim oPartList As PartsList = oPartsList_G
Dim PLRows As PartsListRows = oPartList.PartsListRows
For Each PLRow As PartsListRow In PLRows
Dim ListDoc As Document = PLRow.ReferencedRows.Item(1).BOMRow.ComponentDefinitions.Item(1).Document()
If Not ListDoc.FullFileName = RefDocName Then
PLRow.Visible = False
End If
Next
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingUpdateAllSheetsCmd").Execute
End Sub
If for example, @A.Acheson or @JelteDeJong I adjusted it so that it reacts to both Subassembly and Assembly, it would be generally ideal.