Saturday, January 15, 2011

Use iLogic to fill out your title-block name and date

Issue: 
You have a Drawn By: and a Date: field in your title-block, but it's difficult to remember to edit the iProperties when saving the file, or rolling the revision, etc.


Solution:
Create an iLogic rule to write the User Name ( pulled from Application Options > General tab ) and the current date to the iProperties. You can then set your title block fields to read those iProperties. And then finally set the rule to be triggered using the Before Save Document event trigger so that the title-block is always updated at the time of the file save. (Ribbon: Manage tab > iLogic panel > Event Triggers)


Here is an example snippet, where the user's name is written to the Author iProperty and =Now is used to write the date to the Creation Date iProperty. In this case the If statement is used to check to see if the Author value matches the UserName, if not it sets it to match, then displays a message box. You'll note the message box title uses the UserName to personalize the message:


myName= ThisApplication.GeneralOptions.UserName

If iProperties.Value("Summary", "Author") <> myName Then
iProperties.Value("Summary", "Author") = myName
MessageBox.Show("The Title block has been updated","an iLogic message for: " & myName)
End If

iProperties.Value("Project", "Creation Date") = Now
InventorVb.DocumentUpdate()