Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic Code that worked yesterday seems to make Inventor Crash today

1 REPLY 1
Reply
Message 1 of 2
DonovanCox
219 Views, 1 Reply

Ilogic Code that worked yesterday seems to make Inventor Crash today

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

1 REPLY 1
Message 2 of 2
DonovanCox
in reply to: DonovanCox

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report