Select Active iPart Using Assembly User Parameter

Select Active iPart Using Assembly User Parameter

jdurham67
Explorer Explorer
498 Views
6 Replies
Message 1 of 7

Select Active iPart Using Assembly User Parameter

jdurham67
Explorer
Explorer

Hello, I am struggling to figure out what should be a simple "lookup" command from the assembly environment. I am trying to rely on a user parameter (ANGLE_DROP) in the assembly HS-03-XX.iam to determine which derivation of an angle iPart (iLogic Angle.ipt) to use.  Based on this youtube tutorial I had come across - I thought the solution would be to use the following code:  

 

i = iPart.FindRow("ANGLE:1", "ANGLE_LENGTH", "<=", ANGLE_DROP)

 

 This should find and activate the corresponding row based on a match in the "ANGLE_LENGTH" column, correct? For some reason, it is not working correctly. Any thoughts?

0 Likes
499 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

Do you happen to have the full rule or the section to change the ipart your using? Unfortunately I don't have Inv 2022 so cannot look at the files you have attached.  

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

jdurham67
Explorer
Explorer

There's not much else to see, I was experimenting with other snippets, but it seems to hang on the iPart.findrow.

 

Is there something wrong with the syntax? If not, maybe there is another function I can use to accomplish the task.

 

i = iPart.FindRow("ANGLE:1", "ANGLE_LENGTH", "<=", ANGLE_DROP)


If i = -1 Then 
MessageBox.Show("Cannot find suitable length. Please use whole inch increments from 14in - 144in", "Parameters")

 
ANGLE_DROP = iPart.CurrentRowValue("LENGTH")






End If

 

jdurham67_0-1653481028772.png

 

0 Likes
Message 4 of 7

jdurham67
Explorer
Explorer

I managed to get it working... I think it was just a bug. The reason is was not working before was because the angle.ipt was placed in the assembly prior to becoming an iPart. After placing a new instance of the angle (arbitrarily selecting the member size) I restablished the constraints, renamed the part name in the model browser and edited the code to match the new part name. Once this was done, modifying the user parameter also replaced the iPart member for one with the appropriate length.

0 Likes
Message 5 of 7

A.Acheson
Mentor
Mentor

 I am glad you got it up and running. You can also supply the fullfilename of the ipart instead of just the occurrence name. I have had instances in the past when the file could not be found . It would just keep churning away and failed to bring up an error. If a full file name is given the error is returned instantly shown if the filename is not present. Just giving the occurrence name is the similar to a find command. Great if you have a few files but not if it is maybe stored in a cluttered space. 

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

jdurham67
Explorer
Explorer

When you say full file name, what is the correct syntax for this? I'm not sure if you mean the master file name or something different.

0 Likes
Message 7 of 7

A.Acheson
Mentor
Mentor

My bad I had it wrong from memory. I was referring to adding an ipart and referring to the factory file location. 

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