Part List Ballooned Components Only. Missing attached balloons.

Part List Ballooned Components Only. Missing attached balloons.

davis.j
Advocate Advocate
382 Views
1 Reply
Message 1 of 2

Part List Ballooned Components Only. Missing attached balloons.

davis.j
Advocate
Advocate

This Ilogic rule I have works great but the parts list is not including all of the attached balloons. It seems to look at the last attached balloon and not register the others. Can someone here assist me with this? 🙂

 

Dim oDoc As Document = ThisDoc.Document
oNamer = "BOM PL Balloons"

Dim UNDO As Transaction 
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)

'Your iLogic code goes in here:
'-------------------------------------------------------------------------------------------------------------------------------------
If oDoc.DocumentType <> kDrawingDocumentObject Then
	MessageBox.Show("Run in drawings only!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	Exit Sub
End If

Dim oSheet As Sheet = oDoc.ActiveSheet

If oSheet Is Nothing Then
	MessageBox.Show("Only valid for dwg files with sheets!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop) 
	Exit Sub
End If

If oSheet.PartsLists.Count = 0 Then
	MessageBox.Show("Only valid for sheets with a BOM.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop) 
	Exit Sub
End If

Dim oPL As PartsList = oSheet.PartsLists(1)

If oPL.PartsListRows.Count < 1 Then
	MessageBox.Show("Only valid For partslists With actual rows", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	Exit Sub
End If

If oSheet.Balloons.Count < 1 Then
	MessageBox.Show("Rule only valid For sheets With balloons!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	Exit Sub
End If

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

If Err.Number <> 0 Then
	MessageBox.Show("Issue setting row visibility Or accessing rows...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	End If
Err.Clear

Dim oBalloon As Balloon
Dim oBVS As BalloonValueSet

On Error Resume Next
Dim oIN As String
For Each oBalloon In oSheet.Balloons
	For Each oBVS In oBalloon.BalloonValueSets
		oIN = oBVS.ItemNumber
		If Err.Number <> 0 Then
			MessageBox.Show("Issue grabbing Balloon item number...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
		End If
	Next
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
		MessageBox.Show("Issue iterating PL/setting visibility back On", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
	End If
Err.Clear
Next
	On Error GoTo 0
'-------------------------------------------------------------------------------------------------------------------------------------
UNDO.End

 

0 Likes
383 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

I don't know how your BalloonValueSets looks, but you store ItemNumber only from the last of them. 

For Each oBVS In oBalloon.BalloonValueSets
    oIN = oBVS.ItemNumber
    If Err.Number <> 0 Then
        MessageBox.Show("Issue grabbing Balloon item number...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    End If
Next

The second thing is your use of Transactions

Transaction MUST BE CLOSED in any way. When you end your rule by Exit Sub,  your UNDO transaction MUST be closed with UNDO.End() or UNDO.Abort(). Otherwise, Invnetor crashes  

0 Likes