Inventor Drawing BOM or Parts List To Show Only What Is Ballooned On Each Sheet

Inventor Drawing BOM or Parts List To Show Only What Is Ballooned On Each Sheet

tschaeferZNBXX
Advisor Advisor
5,029 Views
28 Replies
Message 1 of 29

Inventor Drawing BOM or Parts List To Show Only What Is Ballooned On Each Sheet

tschaeferZNBXX
Advisor
Advisor

I have an odd request, does anyone have an idea or add in that will do the follow.

 

On an IDW create a Parts List or BOM for each sheet?  I am looking for an easy way to create this and only show what is ballooned on each sheet of a drawing.

 

kelly.young has edited your subject line for clarity: BOM Question

Thomas "Matt" Schaefer
Engineering Tooling and Vault Manager for Material Handling Systems MHS


*AU Speaker 2018*
* AU Speaker 2017 *
==========================================================
Please use the "Accept as Solution" and "Give Kudos" functions as appropriate to further enhance the value of these forums.
5,030 Views
28 Replies
Replies (28)
Message 21 of 29

davis.j
Advocate
Advocate

Thank you for these contributions. This helps speed up my workflow quite nicely. 😃

0 Likes
Message 22 of 29

ryanTPVFU
Enthusiast
Enthusiast

Is there a way to modify the code to have it work on sheets with multiple parts lists? 

Say by running the code of the selected parts list?

I have to have 2 lists by company standards, one for the components and one for hardware....

0 Likes
Message 23 of 29

A.Acheson
Mentor
Mentor

This can be done. Which version of the code are you using? 

The below will allow user to pick partslist then you can run the rest of the code based on getting this object. 

Dim oPartlist As PartsList
oPartlist = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingPartsListFilter, "Select a Partslist")
 MessageBox.Show(oPartlist.Style.Name, "Title")

Alternatively  build in a separate  filter for each partslist style so no user input required then.  Loop through the partslists collection then get partslist by style name then do something. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 24 of 29

GosponZ
Collaborator
Collaborator

@MechMachineMan Thank you, rule is working perfect, but have another question. If that is possible to renumber Item Numbers in each sheet after rule is done

0 Likes
Message 25 of 29

GosponZ
Collaborator
Collaborator

It turn off all rows if you do not have balloons in drawing(s)

0 Likes
Message 26 of 29

ryanTPVFU
Enthusiast
Enthusiast

Thank you for that mod. below is the code that I am using. When I delete the string that states the "one sheet only" it throws a warning saying that the lines 9 and 10 are inaccessible....I can't seem to figure out how to get this mod to fit into the code.

 

Sub Main()

	Dim oDoc As Document = ThisDoc.Document
    If oDoc.DocumentType <> kDrawingDocumentObject Then: MsgBox("Run in drawings only!"): Exit Sub: End If
        
	Dim oSheet As Sheet = oDoc.ActiveSheet
    If oSheet Is Nothing Then: MsgBox("Only valid for dwg files with sheets!"): Exit Sub: End If
	
    If oSheet.PartsLists.Count <> 1 Then: MsgBox("Only valid for sheets with 1 PartsList"):Exit Sub: End If
	Dim oPL As PartsList = oSheet.PartsLists(1)
	
    If oPL.PartsListRows.Count < 1 Then: MsgBox("Only valid for partslists with actual rows"): Exit Sub: End If
	If oSheet.Balloons.Count < 1 Then: MsgBox("Rule only valid for sheets with balloons!"): Exit Sub: End If

     On Error Resume Next
        For Each oRow In oPL.PartsListRows
		oRow.Visible = False
	Next

       If Err.Number <> 0 Then: MsgBox("Issue setting row visibility or accessing rows..."): End If
       Err.Clear

     On Error Resume Next
        Dim oIN As String
	For Each oBalloon In oSheet.Balloons
		oIN = oBalloon.BalloonValueSets(1).ItemNumber
                If Err.Number <> 0 Then: MsgBox("Issue grabbing balloon item number.."): End If
		Err.Clear

		For Each oRow In oPL.PartsListRows
			If oRow.Item(1).Value = oIN
				oRow.Visible = True
			End If
		Next
                If Err.Number <> 0 Then: MsgBox("Issue iterating PL/setting visibility back on"): End If
                Err.Clear
	Next
     On Error GoTo 0
End Sub 
0 Likes
Message 27 of 29

ryanTPVFU
Enthusiast
Enthusiast

I cant quite figure out where to place this string in the original code. If I delete the line for parts list qty it throws an error. If I your add-in nothing happens..

0 Likes
Message 28 of 29

A.Acheson
Mentor
Mentor

I would suggest create a new post as this may be a complex one to solve and you will get much less eyes on this older post. In a test yesterday I could get it to work but only when the other partslist balloons were removed. This technique works well manually when you filter by visible balloons which is far easier to accomplish. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 29 of 29

BLA_fpineda
Enthusiast
Enthusiast

Hi there,

 

This is a code developed following @MechMachineMan idea.

For all Parts Lists in the Sheet, show only the Ballooned Elements.

 

'Code created by F.PINEDA from BLASAU, S.L.
'For Active Sheet: Show Ballooned Only Elements in the Parts Lists.
Sub
Main 'Check if it's a Drawing Document Dim oDoc As Inventor.Document = ThisApplication.ActiveDocument If (oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject) Then MessageBox.Show("This rule can only be run in Drawing Documents", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument ShowBalloonedOnly(oDrawDoc) InventorVb.DocumentUpdate() End Sub Sub ShowBalloonedOnly(oDrawDoc As DrawingDocument) 'Get Drawing Sheet Dim oSheet As Sheet = oDrawDoc.ActiveSheet 'Get Drawing Parts Lists of the Sheet Dim oPartsLists As PartsLists = oSheet.PartsLists 'Get Drawing Parts List Dim oPartsList As PartsList For Each oPartsList In oPartsLists 'Hide All elements in Parts Lists For Each oPartsListRow In oPartsList.PartsListRows oPartsListRow.Visible = False Next Dim oBalloon As Balloon For Each oBalloon In oSheet.Balloons Dim strItemNumber As String strItemNumber = oBalloon.BalloonValueSets(1).ItemNumber Dim oPartsListRow As PartsListRow For Each oPartsListRow In oPartsList.PartsListRows 'Show Ballooned Only elements If oPartsListRow.Item(1).Value = strItemNumber Then oPartsListRow.Visible = True End If Next Next Next End Sub
0 Likes