iLogic syntax for skipping over an expected error?

iLogic syntax for skipping over an expected error?

claudio.ibarra
Advocate Advocate
586 Views
2 Replies
Message 1 of 3

iLogic syntax for skipping over an expected error?

claudio.ibarra
Advocate
Advocate

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()

 

0 Likes
Accepted solutions (1)
587 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @claudio.ibarra 

 

This should handle the error.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'Find the filename of the model used in the drawing
Try
modeldocname = IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)
Catch
	Return 'exit rule
End Try

EESignature

Message 3 of 3

claudio.ibarra
Advocate
Advocate

Thank you so much!!

0 Likes