Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Component Replace

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
JCollins
1510 Views, 2 Replies

iLogic Component Replace

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

 

 

2 REPLIES 2
Message 2 of 3
cwhetten
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.

Message 3 of 3
JCollins
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report