Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
fred.markle
in reply to: A.Acheson

Got this all up and running. Figured I'd post this here in case anyone else wanted the code. Also added the option to Sort and enable "autosortonupdate".

 

Public Sub PlacePartsList()
    On Error Resume Next
    
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    ' Set a reference to the first drawing view on
    ' the sheet. This assumes the first drawing
    ' view on the sheet is not a draft view.
    Dim oDrawingView As DrawingView
    Set oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to th sheet's border
    Dim oBorder As Border
    Set oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
    If Not oBorder Is Nothing Then
        ' A border exists. The placement point
        ' is the bottom-left corner of the border.
        Set oPlacementPoint = oBorder.RangeBox.MinPoint
    Else
        ' There is no border. The placement point
        ' is the bottom-left corner of the sheet.
        Set oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
    End If
    
    ' Create the parts list.
    Dim oPartsList As PartsList
    If oSheet.PartsLists.Count = 0 Then
        Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
    Else
        Set oPartsList = oSheet.PartsLists.Item(1)
    End If
    
    Dim oPartsListSize As Vector2d
    Set oPartsListSize = ThisApplication.TransientGeometry.CreateVector2d(0, 0)
    oPartsListSize.X = oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X
    oPartsListSize.Y = oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y
    
    oPlacementPoint.X = oPlacementPoint.X + oPartsListSize.X
    oPlacementPoint.Y = oPlacementPoint.Y + oPartsListSize.Y
    
    oPartsList.Position = oPlacementPoint
    
    'PartsList.Sort2( PrimaryColumnTitle As String, [PrimaryColumnAscending] As Boolean, [SecondaryColumnTitle] As String, [SecondaryColumnAscending] As Boolean, [TertiaryColumnTitle] As String, [TertiaryColumnAscending] As Boolean, [SortByString] As Boolean, [AutoSortOnUpdate] As Boolean )
    Call oPartsList.Sort2("ITEM", True, "PART NUMBER", True, "QTY", True, True, True)
    'Call oPartsList.Sort2("ITEM", True, AutoSortOnUpdate, True)

End Sub