<< Part 2
In Inventor 2011 Autodesk added two new parameter types to iLogic – Text and True/False. Previously parameters could only be Numeric. Lets discuss these new parameter types by adding some more logic to our model. Suppose we want to add fillets on all the 12 edges of our box. But we would also like to add chamfers to those same edges and give the user the option to decide whether he wants fillets or chamfers. Furthermore, we would also like the user to decide whether he wants to leave the box as it is and neither add fillets nor chamfers. To encode this logic add two user parameters to the model. User parameters are different from model parameters in the sense that they are not tied to any geometry in the model. Add a multi-value text parameter called Type which can assume values of “Fillet” and “Chamfer”. This will decide whether Inventor should apply fillets or chamfers to the box. Also add another True/False parameter called Modify which will decide whether Inventor should add fillets/chamfers or leave the box as it is.
Next add a fillet feature that fillets all 12 edges of the box. Then add a chamfer feature that chamfers the same 12 edges. In order to add chamfers to the same edges you will need to first suppress the fillet feature. We now need to add more logic to the existing rule so that Inventor can turn the fillet and chamfer features on and off. Append the following code to the end of existing VB code in the rule.
If Modify = FalseFeature.IsActive("Fillet1") = FalseFeature.IsActive("Chamfer1") = FalseElseIf Type = "Fillet"Feature.IsActive("Fillet1") = TrueFeature.IsActive("Chamfer1") = FalseElseFeature.IsActive("Fillet1") = FalseFeature.IsActive("Chamfer1") = TrueEnd IfEnd If
Fillet1 and Chamfer1 are the names of the fillet and chamfer features respectively. We use the Feature.IsActive() function to turn the features on or off depending on the values of Modify and Type. OK, we are all done here. Now let’s test our logic. Invoke the Parameters dialog box, change the values of Type and Modify and notice how Inventor automatically turns the chamfer and fillet features on an off.
Another enhancement to iLogic that I found interesting is a new way of triggering a rule. In previous versions the only way to trigger a rule was to change a parameter value in the Parameters dialog box, like we did above. Now you can set up a rule to be automatically triggered by a user event such as when a user opens/saves/closes a document, suppresses features, changes geometry or material, etc. Since April Fool’s Day is approaching let’s see how we can make use of this new feature of iLogic to scare the crap out of somebody.
Create a new rule called Open and enter the following code for it.
MsgBox(“A serious error has occurred!! Inventor is deleting all the files in your C: drive. To abort the process please close this document immediately”, vbOKOnly, “Inventor 2011”)
Call this rule on the After Open Document event. Create another called Close and enter the following code for it.
MsgBox(“Gotcha!! Here’s wishing you a very Happy April Fool’s Day”, vbOkOnly, “Inventor 2011”)
Call this rule on the Close Document event. Save the Inventor file and send it to someone on the 1st of April. When he opens it this is what he will see.
When he freaks out and hurriedly closes the document this is what will pop up.
In case you need it, you can download the Inventor 2011 file from here. Enjoy!!
Part 4 >>