Having Issues Seeing Linked Parameters on iParts Placed Within An Assembly

Having Issues Seeing Linked Parameters on iParts Placed Within An Assembly

vfantiniN9F39
Explorer Explorer
367 Views
4 Replies
Message 1 of 5

Having Issues Seeing Linked Parameters on iParts Placed Within An Assembly

vfantiniN9F39
Explorer
Explorer

Greetings everyone,

 

I'm having some rather strange issues trying to swap out iParts within an Assembly Model via iLogic, and I'm not certain why.  I've done this particular operation numerous times in the past with other projects of mine, so I know what I'm doing; the only thing that I've noticed that's different this time around is the fact that my iParts' Linked Parameters are causing these unhandled exceptions whenever I attempt to click on them while within the iLogic Rule Editor.

 

Here's my scenario:  I have two iPart components within an Assembly Model.  My iLogic code is currently trying to identify the component that has a name which begins with "BPN"; once found, my code is attempting to ChangeRow from Row 15 to Row 14 (see first attached image).  However, when I attempt to do this I get an iPart.FindRow error saying that the component named "System._ComObject" was not found.

 

Here is my code thus far:

' This rule will extract the W1 & H1 parameters from the Backpan component, and then will adjust the positioning
' and pattern parameters of the Stiffener Angles according to the extracted dimensions.

Sub Main()
	' First, we must properly identify which sub-component within this Assembly Model is the Backpan; the first 3 letters
	' of the Backpan's part number is "BPN".
	Dim oAssyDoc As AssemblyDocument
	oAssyDoc = ThisApplication.ActiveDocument

	' This variable will let us keep track of whether or not we found a Backpan component.
	Dim bFoundBPN, bFoundBSH As Boolean
	bFoundBPN = False
	bFoundBSH = False

	' This will represent our Backpan component occurrence.
	Dim oBPNCompOcc As ComponentOccurrence

	' This will be used to iterate through all of the components within our Assembly Model.
	Dim oCompOcc As ComponentOccurrence

	For Each oCompOcc In oAssyDoc.ComponentDefinition.Occurrences
	'	MsgBox("Left(oCompOcc.Name, 3) = " & Left(oCompOcc.Name, 3))
		If Left(oCompOcc.Name, 3) = "BPN" Then
			' Found it!  Let's assign oCompOcc to oBPNCompOcc and then exit out of this For Each loop.
			oBPNCompOcc = oCompOcc
			bFoundBPN = True
			Exit For
		End If
	Next

	' If bFoundBPN is still set to False, then that means we didn't find the Backpan.  We inform the User, and
	' then exit the procedure.
	If bFoundBPN = False Then
		MsgBox("ERROR:  No Backpan component starting with 'BPN' was found.  Exiting iLogic rule.")
	'	Exit Sub
		
	Else
		' These variables will be used to store the W1 & H1 values from the oBPNCompOcc component.
		Dim W1, H1 As Double
		
		' This will represent oBPNCompOcc's name without the occurrence indicator at the end of the name (":1").
		Dim sBPNName As String
		sBPNName = Left(oBPNCompOcc.Name, oBPNCompOcc.Name.Length - 2)

' HERE is where Inventor gets angry with me.
		i = iPart.FindRow(oBPNCompOcc, "H1", "=", 72.5, "W1", "=", 109.875)
		iPart.ChangeRow(oBPNCompOcc, i)
	End If
End Sub

 

Interestingly enough, when I expand the BPN component in the Model Tree within the iLogic Rule Editor and then attempt to click on the Linked Parameters, I get an unhandled exception error (see second attached image).

 

It's so strange because I use the same code as shown above for some older iPart manipulating iLogic code that I've done with previous editions of Inventor (2020, to be precise), and the Linked Parameters work just fine (see third attached image)!

 

I don't understand why the Linked Parameters for my BPN component causes this strange error to appear, and yet my older iPart components are perfectly fine.  Would anybody have any insight as to what I can do to make these things play nicely with each other?

0 Likes
368 Views
4 Replies
Replies (4)
Message 2 of 5

CattabianiI
Collaborator
Collaborator

However, when I attempt to do this I get an iPart.FindRow error saying that the component named "System._ComObject" was not found
This is because FindRow first parameter is the name of the occurrence not the occurrence itself.
So change the line 46 with something like this: 

i = iPart.FindRow(oBPNCompOcc.Name, "H1", "=", 72.5, "W1", "=", 109.875)

some thing for ChangeRow the line after.

0 Likes
Message 3 of 5

vfantiniN9F39
Explorer
Explorer

@CattabianiIThank you kindly!  That did indeed allow my code to run and switch rows properly.  However, I'm still perplexed as to why the Linked Parameters still kick up that unhandled exception error.  Would you happen to have any insight as to what could cause such an error to occur?

 

I typically rely on the Linked Parameters to work my usual coding magic, but in this instance I'm finding that I have to do some rather ridiculous work-arounds to get around this blockade.  Getting some insight as to what causes this unhandled exception error to pop up in one instance when it works just fine in other instances would be invaluable to getting around this problem.

0 Likes
Message 4 of 5

CattabianiI
Collaborator
Collaborator

hi @vfantiniN9F39 ,
I found out what the issue is:

you're clicking on an iPart instance, which is a sheet metal and have some linked parameters.

Remove if possible one of these traits and everything will be ok. If it's not possible wait for an answer by Autodesk here. (I've done another post because unanswered post are more visible that answered one, and in a certain way I already found out the issue on the code you posted 😉 so let's wait for an official answer.) 
This is  the new post: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/bug-report-exception-clicking-on-lin...

Message 5 of 5

vfantiniN9F39
Explorer
Explorer

@CattabianiIAh, thank you for informing me of your bug report! Here's hoping that we hear back from Autodesk sooner than later!

0 Likes