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: 

Use parameter to define part name in rules

2 REPLIES 2
Reply
Message 1 of 3
Heatnix
338 Views, 2 Replies

Use parameter to define part name in rules

Hi.

I want to use a parameter in my assembly as the name of a part i'm referring to in a rule but so far I have had no luck making it work. My knowledge of iLogic is pretty limited.

 

I am making a configurator for a staircase and I am working on the stringers now. There will be 3 or 4 different stringers (each one is a separate part) and the configurator lets you choose things like the angle, length and height of the staircase by entering values for those in a form in the assembly. Once you are done entering the values, there will be an update button that will send all the parameters to the different parts that are in the assembly and have them change accordingly. Now, say I want the length to change. I enter a length and press update and here's my problem. To which stringer-part is it going to send the length to? I can make it send to all parts but that means that I have to write one line of code for each part and if I ever add a new kind of stringer, I need to check all the rules and new lines where needed. I would like to make this dynamic by having only one line in which the part name is the same as a parameter I have in my assembly

 

I can either write it like this:

Parameter("Stringer1:1", "Length") = Length

Parameter("Stringer2:1", "Length") = Length

Parameter("Stringer3:1", "Length") = Length

Parameter("Stringer4:1", "Length") = Length

 

But I would like to write it like:

Parameter(""Assemblyparameter":1", "Length") = Length

 Where Assemblyparameter is a text parameter and simply the name of the part that is inserted.

 

When I choose, for example, stringer 3 in my form, Assemblyparameter will be Stringer3. This would save lots of time in the future whenever new parts are added.

 

I hope I explained this good enough.

 

Any help would be greatly appreciated.

 

 / Peter Ö

 

2 REPLIES 2
Message 2 of 3
cwhetten
in reply to: Heatnix

Hi and welcome to the forum!

 

Try something like this:

 

Parameter(Assemblyparameter & ":1", "Length") = Length

If this doesn't work, try this instead:

 

oCompName = Assemblyparameter & ":1"
Parameter(oCompName, "Length") = Length

You can concatenate separate text entities (link them together in a series) into a single text string by using & between them.

 

I wonder if there is an even better way of solving this problem, however.  How exactly are you making it change between the three stringer types?  Are you using component suppression, visibility, or maybe component replace?  Depending on how you are doing this, there may be a more elegant solution.

 

Cameron Whetten
Inventor 2012

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

Message 3 of 3
Heatnix
in reply to: cwhetten

Thank you very much for the explanation and examples you provided. I will test them after the weekend.

The assembly will contain every part that can be chosen and those will be mated together. The ones that are not selected in the form will stay suppressed and will be deleted when the user is done with the configuration.

In short: if stringer 3 is selected, stringer 1, 2 and 4 will be suppressed. Should the user decide on using stringer 1 instead, stringer 1 will be unsuppressed and stringer 3 will become suppressed.

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

Post to forums  

Autodesk Design & Make Report