Launch EA Programmatically

走远了吗. 提交于 2019-12-01 14:27:02

the code sample below demonstrate how to open EA COM Object and open EA project file then get list of the project models

// connect to EA COM object     
EA.Repository _repository = new EA.RepositoryClass();
// Open EA project file
bool fileOpened = _repository.OpenFile(filePath);
if(fileOpened)
   Collection models = _repository.Models; // collection of models inside of opened project

Add a reference to Interop.EA.dll and use

EA.Repository repository = new EA.RepositoryClass();

To open a running instance use (C++ example)

CLSID clsid;
CLSIDFromProgID(L"EA.App", &clsid);
IUnknown *pUnk = NULL;
IDispatch *pDisp = NULL;
HRESULT hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
if(SUCCEEDED(hr)) {
  hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!