Ilogic Code that worked yesterday seems to make Inventor Crash today

Ilogic Code that worked yesterday seems to make Inventor Crash today

Anonymous
Not applicable
322 Views
1 Reply
Message 1 of 2

Ilogic Code that worked yesterday seems to make Inventor Crash today

Anonymous
Not applicable

Cut and paste some code together that fetches the mass of a part or assy that's in a drawing, and then write that to a custom property in kg & lbs that's shown in the titleblock. Last night it worked, but today running it seems to cause Inventor to crash. 

 

Some of it came from a post Curtis_Waguespack made here

 

http://forums.autodesk.com/t5/inventor-general-discussion/using-ilogic-to-retrieve-iproperties-form-...

 

and some of it here http://blogs.rand.com/manufacturing/2011/07/inventor-ilogic-mass-to-custom-iproperties.html

 

 

Here's the code, I can't figure out what would make it crash, the only system change was that I installed Flash

 

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'Look at the model file referenced in the open document
Dim docFile As Document
If ThisDoc.ModelDocument IsNot Nothing Then
docFile = ThisDoc.ModelDocument
Else
MessageBox.Show("This drawing has no model reference", "iLogic")
Return
End If
'format model file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
'Get Mass of Model, convert to lbs, write to custom iproperty
Cmass = iProperties.Mass(docFName)
Round_Mass_lbs = Round(Cmass * 2.20462, 2)
Round_Mass_kg = Round(Cmass, 2)
iProperties.Value("Custom", "Mass") = Round_Mass_kg & "kg" & " " & "(" & Round_Mass_lbs & "lbs)"

0 Likes
323 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

I just figured out what I did wrong. All the testing was done on the drawing I was making, the code was copied to the template but I forgot to add the parameters Round_Mass_lbs and Round_Mass_kg

0 Likes