iLogic External Rules and Forms are tailor-made to help you control the more universal elements behind your design process. In this series of articles we’ll take a look at how we can leverage this technology to help you gain more control of your design data.
This sample will illustrate a technique for prompting a user to identify a designation or identifier that we would like to be entered as an iProperty in the “Title” area of the iProperty “Summary” Tab.
We want this rule to be fired every time an new design is started regardless of the template used. The information in this rule could also be dynamic and having to modify a local rule in each and every model, drawing, or assembly in which it was used would be highly impractical so leveraging an illogic External Rule is ideal.
Simply start a new document and right-mouse click in the External Rules tab of the iLogic Browser and select “Create New External Rule” to start the iLogic Rule Editor.
You will be prompted to save the rule to some location. This could be anywhere within the project path or can be put on a network share. You can choose the file extension that best suites your needs but I like to use *.iLogicVB so I know exactly what the file is on disc. Call the rule “PromtforTitleOnOpen”.
Note: Should you choose to store your external rules outside the Inventor Project path you will need to specify that location to the list of external rules directories. You will find this specification in the Tools Tab. Select the little down arrow on the Options Panel.
Add the following code:
'list the categories to choose from and hold in a variable
Category = New String(){"", "Drive", "Sheet Metal", "Console", "Engine", "Plate", "Framework", "Wave", "Angle"}
'Listbox holding the category string
Category = InputListBox("Designation Catalog", Category, Category, Title := ThisDoc.FileName(True) , ListName := "Choose a Designation Catalog")
'check for an empty title field and prompts for entry
If Category = "" Then
Category = InputBox("Choose a Designation Catalog", "iProperties Title Category", "Designation Catalog")
End If
'writes the selection to the iProperties
iProperties.Value("Summary", "Title") = Category
The code for this experiment will do a couple of things. First it will create a local variable named “Category” that will hold a string of values we want the user to choose from.
- “ ” (an empty or blank selection), “Drive”, “Sheet Metal”, “Console”, “Engine”, “Plate”, “Framework”, “Wave”, “Angle”
The rule will then check to see if the Title iProperty is empty and if it is, prompt for an input serving sort of a “trap” allowing a user to add a custom input that may not be in the original list.
Finally the rule will populate the appropriate iProperty with the selection or the custom input value.
Use can use an event trigger on your template to make the rule fires at an appropriate time (“After Open” or “New Document” for example).
You don’t have to use the iLogic rule editor to make changes to this rule. It is simply a text file that can be edited with any text editor allowing for a “master” rule whose logic will be instantly applied to every Inventor file when it’s opened.
Have fun!
This comment has been removed by the author.
ReplyDelete