- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Inventor Forum,
This is a question about Inventor Ilogic. I have an assembly with 5 parts that are all the same except for a difference in height. The part names are "Part: 1", "Part: 2", Part: 3" etc. The height parameters are "PartHeight1", "PartHeight2", "PartHeight3" etc. I also have a parameter "NumberOfParts" which dictates how many of the parts are present in the assembly.
I want to write a for loop such that:
for i in range(0, NumberOfParts):
PartHeight[i] = InputBox("What is the Height of Part" + str(i), "Part Height")
end for loop
I could also do the same thing with a while loop:
i = 0
while i<NumberOfParts
i=i+1
PartHeight[i] = InputBox("What is the Height of Part" + str(i), "Part Height")
end While
My question is: How do I index the parameter name "PartHeight1", "PartHeight2", "PartHeight3" etc. during the loop? It throws a syntax error if I do something like ("PartHeight"+str(i)) = InputBox(....). Is there a way to index through the names?
I would rather not hard code in the numbers, because the number of parts in the assembly can increase beyond the point of convenient hard coding.
Thank you!
Nicholas
Solved! Go to Solution.