Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic Rule if no Parameters exist

2 REPLIES 2
Reply
Message 1 of 3
DustinSmith7222
2238 Views, 2 Replies

ilogic Rule if no Parameters exist

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??

2 REPLIES 2
Message 2 of 3
MegaJerk
in reply to: DustinSmith7222

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!



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 3
MjDeck
in reply to: MegaJerk

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  

 

 


Mike Deck
Software Developer
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report