Message 1 of 4
Unspecified error occured on document.Close() method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
I am having an issue with opening and closing files in Autodesk Inventor.
The task is to update iProperties on currently edited part, but to do that I must open it, get specific data from view cube orientation and according to that data update iProperties.
Attached is an image of workspace and error message. I think the problem is that I need to do that from an assembly document when I am returning to it (from activated part).
I wanted to do that with onEnvironmentChange event, but unfortunately I wasn't successful. Any ideas or workarounds please?
private void UserInterfaceEvents_OnEnvironmentChange(Inventor.Environment environment, EnvironmentStateEnum environmentState, EventTimingEnum beforeOrAfter, NameValueMap context, out HandlingCodeEnum handlingCode)
{
try
{
string envInternalName = environment.InternalName;
// Check if we are in the part environment
if (envInternalName == "PMxPartEnvironment")
{
// When resuming or activating the part environment, store the part document reference
if (environmentState == EnvironmentStateEnum.kActivateEnvironmentState || environmentState == EnvironmentStateEnum.kResumeEnvironmentState)
{
activeEditedDocument = m_inventorApp.ActiveEditDocument;
}
// When suspending or terminating the part environment, open and close the stored part document
if (environmentState == EnvironmentStateEnum.kTerminateEnvironmentState || environmentState == EnvironmentStateEnum.kSuspendEnvironmentState && activeEditedDocument != null)
{
// Open and immediately close the stored part document
// Add your logic here for opening and closing the document
// For example:
if (beforeOrAfter == EventTimingEnum.kBefore)
{
m_inventorApp.Documents.Open(activeEditedDocument.FullFileName, true);
activeEditedDocument.Close();
}
else if (beforeOrAfter == EventTimingEnum.kAfter)
{
m_inventorApp.Documents.Open(activeEditedDocument.FullFileName, true);
activeEditedDocument.Close();
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
handlingCode = HandlingCodeEnum.kEventNotHandled;
}