Inventor General Discussion

Inventor General Discussion

Reply
Member
JCollins
Posts: 4
Registered: ‎10-28-2013
Message 1 of 3 (433 Views)
Accepted Solution

iLogic Component Replace

433 Views, 2 Replies
12-02-2013 05:27 PM

Hi All,

 

I want to replace some library parts size's in an assembly, based on a parameter from the master sketch, using iLogic.

 

I had previously seen a thread on arrays so based it on that, but need alot of help.

 

Code:

 

For i = Parameter("PM900-422-01-F15.4-00-001:1", "Mid_Pipe_Nominal_Bore")
Component.Replace("Expansion Joint Pump 1", "..\Libraries\Standard Parts\Expansion Joints\"DN" & i "Tyco FTF Bellows Flanged ASME 150#.ipt") = False
Next

 

'"PM900-422-01-F15.4-00-001:1", "Mid_Pipe_Nominal_Bore" is the master sketch and size parameter. the sizes range from 50-350

'"Expansion Joint Pump 1" is the library part (renamed in browser) and i also need to replace "Expansion Joint Pump 2" which i have not written into the statement above.

'DN80 Tyco FTF Bellows Flanged ASME 150#.ipt is the file name of the library part, but all size from DN50 to DN350 can be found in the library.

 

I am currently doing this using a Select Case, but it seems a bit long winded. If anyone has any better ideas i would love to here them.

 

Cheers

 

 

Hi and welcome to the forum!

 

I don't quite understand your usage of the For...Next statement.  Typically, For...Next statements are used to loop through some lines of code a set number of times.  The number of times it loops is controlled by the counter variable (usually i), and the range specified in the argument.  Specifying a range usually requires the word "To".  So, for example, you could write a For...Next loop like so:

 

For i = 1 To 7

    Some code goes here

Next

 

This would run the code once, then increment the i variable to 2, run the code again, increment i to 3, etc.  Once i is incremented to 7, it would run the code one last time then exit the loop.

 

In the code you posted, there is no range specified for i.  In fact, I suspect that you don't really need a loop to do what you want.  Also, you set the Component.Replace statement = False.  I'm not sure what you intended here, but the correct syntax for specifying the "replace all" argument is inside the parentheses (see the code below for the correct syntax).

 

I think the following code would work for you:

 

i = Parameter("PM900-422-01-F15.4-00-001:1", "Mid_Pipe_Nominal_Bore")
Component.Replace("Expansion Joint Pump 1", "..\Libraries\Standard Parts\Expansion Joints\"DN" & i "Tyco FTF Bellows Flanged ASME 150#.ipt", False)
Component.Replace("Expansion Joint Pump 2", "..\Libraries\Standard Parts\Expansion Joints\"DN" & i "Tyco FTF Bellows Flanged ASME 150#.ipt", False)

 This will replace each component (Pump 1 & Pump 2).

 

Post back if you have more questions.

 

Cameron Whetten
Inventor 2014

Please click "Accept as Solution" if this response answers your question.

*Expert Elite*
cwhetten
Posts: 1,074
Registered: ‎09-03-2008
Message 2 of 3 (396 Views)

Re: iLogic Component Replace

12-05-2013 10:07 AM in reply to: JCollins

Hi and welcome to the forum!

 

I don't quite understand your usage of the For...Next statement.  Typically, For...Next statements are used to loop through some lines of code a set number of times.  The number of times it loops is controlled by the counter variable (usually i), and the range specified in the argument.  Specifying a range usually requires the word "To".  So, for example, you could write a For...Next loop like so:

 

For i = 1 To 7

    Some code goes here

Next

 

This would run the code once, then increment the i variable to 2, run the code again, increment i to 3, etc.  Once i is incremented to 7, it would run the code one last time then exit the loop.

 

In the code you posted, there is no range specified for i.  In fact, I suspect that you don't really need a loop to do what you want.  Also, you set the Component.Replace statement = False.  I'm not sure what you intended here, but the correct syntax for specifying the "replace all" argument is inside the parentheses (see the code below for the correct syntax).

 

I think the following code would work for you:

 

i = Parameter("PM900-422-01-F15.4-00-001:1", "Mid_Pipe_Nominal_Bore")

Component.Replace("Expansion Joint Pump 1", "..\Libraries\Standard Parts\Expansion Joints\"DN" & i "Tyco FTF Bellows Flanged ASME 150#.ipt", False)

Component.Replace("Expansion Joint Pump 2", "..\Libraries\Standard Parts\Expansion Joints\"DN" & i "Tyco FTF Bellows Flanged ASME 150#.ipt", False)

 This will replace each component (Pump 1 & Pump 2).

 

Post back if you have more questions.

 

Cameron Whetten
Inventor 2014

Please click "Accept as Solution" if this response answers your question.

Member
JCollins
Posts: 4
Registered: ‎10-28-2013
Message 3 of 3 (388 Views)

Re: iLogic Component Replace

12-05-2013 10:55 AM in reply to: cwhetten

Hi Cameron,

 

Thanks for your reply, it worked a treat. Your explanation was excellent, and yes i ended up changing the Flase statement to True.

 

Cheers,

 

James

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.