I think the code below will get you close to what you want (not perfect as it requires some prior setup). I have commented out some lines that will require you to edit them to call out the correct iProperty fields and rename the columns to sort by.
The gist of the code is that you will have setup two additional iProperty fields, one for Component Priority (Valves, Flanges, etc) and then by increasing dimension size. I am leaving the iProperty fields up to you but can help if needed. My recommendation is that Valves are given a value of 1, Flanges a value of 2, so on and so forth. Then in the other iProperty field given the dimensional value.
If this is done it should sort based on those fields and shrink the columns' width to zero, hiding the unnecessary columns/iProperty fields.
I will try to answer any questions you may have as quickly as possible.
Here is the code:
'Check that file is drawing document
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
Return
End If
'Initialize to document
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView
'Check for View
If oSheet.DrawingViews.Count > 0 Then
oView = oSheet.DrawingViews.Item(1)
Else
MsgBox("There was no view on the Active Sheet to base the Parts List on. Exiting.", vbOKOnly + vbExclamation, "No View")
Return
End If
'Check for Border
Dim oBorder As Border = oSheet.Border
Dim oPoint As Point2d
If oBorder IsNot Nothing Then
' A border exists. The placement point
' is the top-right corner of the border.
oPoint = oBorder.RangeBox.MaxPoint
Else
' There is no border. The placement point
' is the top-right corner of the sheet.
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)
End If
'Call Parts List Default
Dim oPListStyle As PartsListStyle = oDDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)")
Dim oPList As PartsList = oSheet.PartsLists.Add(oView, oPoint, PartsListLevelEnum.kStructured)
Dim oColumns As PartsListColumns = oPList.PartsListColumns
Dim oCol As PartsListColumn
'Title and Heading Setup
oPList.Style = oPListStyle
oPList.Title = "Parts List"
oPList.ShowTitle = True
oPList.HeadingPlacement() = kHeadingAtTop
oPList.TableDirection() = kTopDownDirection
'Add Columns
'Dim oSumSet As PropertySet = oDDoc.PropertySets.Item("Inventor Summary Information")
'Dim oPropSetID As String = oSumSet.InternalName
'Dim oTitle As [Property] = oSumSet.Item("Title")
'Dim oTitleId As Integer = oTitle.PropId
Dim oDTPropSet As PropertySet = oDDoc.PropertySets.Item("Design Tracking Properties")
Dim oDTPId As String = oDTPropSet.InternalName
'Dim oVendor As [Property] = oDTPropSet.Item("Vendor")
'Dim oVendorId As Integer = oVendor.PropId
Dim oDesc As [Property] = oDTPropSet.Item("Description")
Dim oDescId As Integer = oDesc.PropId
oColumns.Item(4).Remove
oColumns.Item(3).Remove
oColumns.Add(PropertyTypeEnum.kFileProperty, oDTPId, oDescId)
'oColumns.Add(PropertyTypeEnum.kFileProperty, oPropSetID, oTitleId)
'oColumns.Add(PropertyTypeEnum.kFileProperty, oDTPId, oVendorId)
'Format Column Names and Justification
oColumns.Item(1).Title = "ITEM"
oColumns.Item(2).Title = "QTY"
oColumns.Item(3).Title = "DESCRIPTION"
'oColumns.Item(3).Title = "Primary Column Title"
'oColumns.Item(4).Title = "Secondary Column Title"
PartsList.sort("Primary Column Title", True, "Secondary Column Title", True)
'Setting the Column Widths
For Each oCol In oColumns
Select Case oCol.Title
Case "ITEM"
oCol.Width = .889
Case "QTY"
oCol.Width = .889
Case "DESCRIPTION"
oCol.Width = 3.683
' Case "Primary Column Title"
' oCol.Width = 0.0000
' Case "Secondary Column Title"
' oCol.Width = 0.0000
End Select
Next