Save command during OnNewView Event causes inventor 2008 SP3 to crash

Save command during OnNewView Event causes inventor 2008 SP3 to crash

Anonymous
Not applicable
346 Views
1 Reply
Message 1 of 2

Save command during OnNewView Event causes inventor 2008 SP3 to crash

Anonymous
Not applicable


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.

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

Anonymous
Not applicable
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}
0 Likes