Issue:
You've found some iLogic code online, but you're not sure how to create a simple rule or have it trigger on a save event. You've found the iLogic tutorials on line, but don't have the time to go through them right now. You really just want to know how to create a simple rule and get it working.
Solution:
Here are some basics to get you going, using some simple example code to update the creation date and author iProperties, as described at this link.
Here is the iLogic Code you'll use:
'set Author iproperty to match the system user name
iProperties.Value("Summary", "Author" ) = ThisApplication.GeneralOptions.UserName
'set the Creattion Date iproperty to the current date
iProperties.Value("Project", "Creation Date" ) = Now
'update the file
iLogicVb.UpdateWhenDone = True
To use this code first create an iLogic Rule:
- On the ribbon, click Manage tab > iLogic panel > Add Rule button.
- Name the new rule Name-Date.
- In the rule text area of the Edit Rule dialog box, simply paste in the code from above.
- Click OK to save this new rule.
Next you need to have a couple of text fields that read the iProperties (you'd likely create these text objects in your title block, but for now just create some simple text on your drawing to test this first).
- On the ribbon, click Annotate tab > Text panel > Text button.
- Click on screen to place the text
- In the Format Text dialog box select the Type pull down and choose Properties - Model from the list.
- Then select the Property pull down and choose Creation Date from the list.
- Then click the Add Text Parameter button (looks like and X with an arrow) to "push" the field to the text box.
- Click OK to create the text.
- Repeat these steps for the Author iProperty
Next set the rule to trigger when the file is saved.
- On the ribbon, click Manage tab > iLogic panel > Event Triggers button. A dialog box displays the list of available events.
- Click the Before Save Document event in the list.
- Click Select Rules, or right-click and choose Select Rules from the context menu.
- Place a check mark next to the Name-Date rule.
- Click OK.
- Click OK to close the event list.
Now whenever this file is saved the date and name text fields are updated.
Note:
You might also be interested in this post from the guys at the Being Inventive blog:
http://beinginventive.typepad.com/being-inventive/2011/07/plot-date-stamp-in-title-block.html
And this article from Paul Munford:
http://www.augi.com/library/playing-by-the-ilogic-rules
And this article from Steve Bedder:
http://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html
Note:
You might also be interested in this post from the guys at the Being Inventive blog:
http://beinginventive.typepad.com/being-inventive/2011/07/plot-date-stamp-in-title-block.html
And this article from Paul Munford:
http://www.augi.com/library/playing-by-the-ilogic-rules
And this article from Steve Bedder:
http://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html