Issue:
You purchase stock lengths of material, and then cut them to length. You want to assign a part number based upon the part length so that if the part falls into a given range it receives one part number, and if it falls into another range it receives a different part number, and so on. Thus assigning part numbers based on the stock material lengths.
Solution:
- First a multi-value parameter is created and the stock sizes are added to the list, in this case the list is a user parameter called Size.
- Next an iLogic rule is created, and an input box is set to read the multi-value list, so the user can select one of the stock sizes.
- Then a model parameter called Length is set to equal the user parameter called Size.
- The part is updated to reflect the parameter change
- A conditional if/then evaluates the length parameter and sets the part number iProperty based on the Length of the part.
- And finally a message box displays the assigned part number for confirmation.
Click to Enlarge |
'get size from list
Size= InputListBox("Choose Size", MultiValue.List("Size"), _
Size, Title := "Select Size", ListName := "Available Sizes")
'set length to be Size
Length = Size
'update the part to reflect the parameter change
iLogicVb.UpdateWhenDone = True
If Length <= 250 Then
iProperties.Value("Project", "Part Number") = "000-10"
Else If Length <= 500 Then
iProperties.Value("Project", "Part Number") = "000-20"
Else
iProperties.Value("Project", "Part Number") = "000-30"
End If
'evaluates the length parameter and sets the part number iProperty
PN =iProperties.Value("Project", "Part Number")
'displays the Partn number in a message box.
MessageBox.Show("Part Number: " & PN, "Part Number Confirm",MessageBoxButtons.OK)
This shows the rule in action, with the part number range scale sketched for illustration purposes. If the length is 250 or less then the part number is 000-10, if its over 250 and less than or equal to 500, then it is 000-20, for anything over 500 the part number is 000-30.
Click to Enlarge |
Click here to download the example file (Inventor 2011)
The file is called PN Range From List.ipt
Look for more iLogic examples on this blog or in the chapter dedicated to iLogic Basics in the next edition of Mastering Autodesk Inventor book (due out in June of 2011 if all goes well).
The file is called PN Range From List.ipt
Look for more iLogic examples on this blog or in the chapter dedicated to iLogic Basics in the next edition of Mastering Autodesk Inventor book (due out in June of 2011 if all goes well).