I am trying to create an ilogic rule that will fill in the part number and set the thickness of a part after a certain parameter is created.
Basically, once the operator has selected a certain material type, then created a parameter called THK, the part number would be filled in from the ilogic rule. The problem I am having is that the ilogic rule errors out if the user does not create the parameter, where in fact, I would like the rule to either not run, or ignore that part of the code when the user has not created the specific parameter. This way, we can use the standard part template for more than one type of part, (ie the same part template might be used for sheet metal, or a piece of plastic).
I have attached a sample part with the rule built in. Any suggestions??
If you'd like it to ignore any Parameters that you haven't actually created yet, then add this line of code to your rule
Parameter.Quiet=True
It will keep Inventor from throwing up any errors at you when things haven't technically been made yet.
Hope that helps!
Parameter.Quiet = True will get rid of the error messages.
If you want more control over whether the rule will run or not, you can add these lines to the top of your rule:
Dim partDoc as PartDocument = ThisDoc.Document Try THK_param = partDoc.ComponentDefinition.Parameters("THK") WIDTH_param = partDoc.ComponentDefinition.Parameters("WIDTH") LENGTH_param = partDoc.ComponentDefinition.Parameters("LENGTH") Catch Return ' exit from the rule End Try