05-04-2023
09:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-04-2023
09:08 AM
I modified the main Sub with this and it seems to work now, by counting only the Visible rows.
If you have any input, to make it simpler or better please share it. I always appreciate it!
Sub Main() If Not ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then MessageBox.Show("Hey this rule only runs in drawing documents!") Exit Sub End If Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheets As Inventor.Sheets = oDrawDoc.Sheets Dim oLongestPL As PartsList = Nothing Dim iMostRows As Integer = 0 Dim iSheetNumber As Integer = 0 For Each oSheet As Inventor.Sheet In oSheets Dim oPLs As PartsLists = oSheet.PartsLists If oPLs.Count = 0 Then Continue For For Each oPL As PartsList In oPLs Dim i As Long Dim oVisibleRows As Integer = 0 For i = 1 To oPL.PartsListRows.Count Dim oRow As PartsListRow oRow = oPL.PartsListRows.Item(i) If oRow.Visible = True Then oVisibleRows = oVisibleRows + 1 End If Next If oVisibleRows > iMostRows Then iMostRows = oPL.PartsListRows.Count oLongestPL = oPL iSheetNumber = CInt(oSheet.Name.Split(":").Last) End If Next Next ExportPartsList(oDrawDoc, oLongestPL) End Sub