Opening an assembly in C++

I've been trying to open an assembly in C++, but I keep running into the problem of the SEHException being thrown.   Here is the jist of the code I have:

ApplicationPtr pApp;DocumentsPtr pDocuments = NULL;AssemblyDocumentPtr pAssem;hr = CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY );if (FAILED(pApp.GetActiveObject("SolidEdge.Application"))){hr = pApp.CreateInstance("SolidEdge.Application");if (!FAILED(hr)){DocumentsPtr pDocs;pDocs = pApp->GetDocuments();pAssem = pDocs->Add("SolidEdge.AssemblyDocument", NULL);}}else{pAssem = pApp->GetActiveDocument();}pDocuments = pApp->GetDocuments();pDocuments->Open(strFileName.m_str, strEmpty.m_str, strEmpty.m_str, vtTrue, rroRevisionRuleType, vtFalse);

I have a similar block in C#, and it seems to open the assembly just fine, but I'm running into other exceptions when I try to assign the equivalent of pDocuments->Item(1) to just about anything I could try.  I'm also limited in C# since I'm not familiar enough with the language, and I don't have the time to learn it properly.

Any assistance on this would be great.  What I'm ultimately trying to do is open an assembly, replace a part (as necessary), and modify some variables associated with parametric attributes.

Thanks,Daniel

 

 

Posted by: Daniel S
Post date: 1/26/2011 10:08:06 AM

2 REPLIES

RE: Opening an assembly in C++

Daniel,I was working on an example for you when I decided to put together a demo project and post it in the Community Contributions forum. You can view my post here.

 

Posted by: Jason Newell
Post date: 1/26/2011 1:00:46 PM

RE: Opening an assembly in C++

Thank you. That looks like something I can start with.

 

Posted by: Daniel S
Post date: 1/27/2011 11:16:04 AM