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
Solved! Go to Solution.
Solved by cwhetten. Go to Solution.
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.
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.