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: 

Save command during OnNewView Event causes inventor 2008 SP3 to crash

1 REPLY 1
Reply
Message 1 of 2
Anonymous
332 Views, 1 Reply

Save command during OnNewView Event causes inventor 2008 SP3 to crash


Hi Guys,





I have a problem with a c# .net 2.0 AddIn I am writing for Inventor 2008. In a nutshell the AddIn needs to monitor files as they open, check/update their iProprerties then perform a save. However, since installing SP3 (also SP2 has the problem) when I issue a save from within the OnNewView Event, Inventor locks up then eventually crashes. This has previously been ok in Inventor 11 and Inventor 2008 SP0. I can reproduce the error with the code below:





void AppEvents_OnNewView(View ViewObject, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)



{



try



{



if (BeforeOrAfter == EventTimingEnum.kAfter)



{



//Add a new iProperty



ViewObject.Document.PropertySets["{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"].Add("Test2", "TestVal", null);



//Save the file



ViewObject.Document.Save();



}



}



catch (Exception ex)



{



System.Windows.Forms.MessageBox.Show(ex.ToString());



}



finally



{



HandlingCode = HandlingCodeEnum.kEventHandled;



}



}





No error is raised in the error trap and control is correctly handed back to Inventor which then locks up and crashes. If I run the code above but comment out the Save() it never crashes.





Whilst it seems strange to perform a save during the opening of a document it is essential the AddIn works this way.





Any ideas why this happens???





Many thanks,





Adrian.

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

Furthur to my last post this actually effects all version of Inventor 2008 not just SP2 & SP3.

Also, here is my code again formatted correctly (hopefully).

{code}

void AppEvents_OnNewView(View ViewObject, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
try
{
if (BeforeOrAfter == EventTimingEnum.kAfter)
{
//Add a new iProperty
ViewObject.Document.PropertySets["{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"].Add("Test2", "TestVal", null);
//Save the file
ViewObject.Document.Save();
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
finally
{
HandlingCode = HandlingCodeEnum.kEventHandled;
}
}

{code}

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

Post to forums  

Autodesk Design & Make Report