Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I stole borrowed an iLogic rule I found in the forums for putting weight in the title block without "lbmass". I made some changes to round the resultant based on the weight value, but other than that the rule is pretty much untouched.
The rule is fired on the "before save" event trigger. But that means the user gets an error if the drawing is saved before adding a model. Normally that doesn't happen, but it can happen (and does with the drawing template).
What's the syntax for skipping over that error?
Text of the rule, below:
doc = ThisDoc.Document customPropertySet = doc.PropertySets.Item("Inventor User Defined Properties") 'Make sure TotalWT property exists Try prop = customPropertySet.Item("TotalWT") Catch 'Assume error means not found customPropertySet.Add("", "TotalWT") End Try 'Find the filename of the model used in the drawing modeldocname = IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName) 'Find the mass of the model used in the drawing mass_in_kg = iProperties.Mass(modeldocname) 'Convert the mass to lbs mass_in_lbs = mass_in_kg * 2.20462 'Write the mass of the model to the TotalWT custom iProperty. If mass_in_lbs >= 10 'If the mass is greater than or equal to 10 lbs, no decimal place. iProperties.Value("Custom", "TotalWT") = Round(mass_in_lbs, 0) ElseIf mass_in_lbs <= 1 'If the mass is less than or equal to 1 lb, 2 decimal places. iProperties.Value("Custom", "TotalWT") = Round(mass_in_lbs, 2) Else 'If the mass is between 1 and 10 lbs, 1 decimal place. iProperties.Value("Custom", "TotalWT") = Round(mass_in_lbs, 1) End If InventorVb.DocumentUpdate()
Solved! Go to Solution.