Hi,
You can try to get IAcadApplication using the following way:
AutoCAD::IAcadApplication *pAcad;
HRESULT hr = NOERROR;
LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE);
if(pAcadDisp==NULL)
return;
hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,
(void**)&pAcad);
pAcadDisp->Release();
if (FAILED(hr))
return;
However as the tlb is different in MDT2004 ("acax16enu.tlb") and MDT2007
("acax17enu.tlb"), you will need to import and build with the respective tlb
for MDT2004 and MDT2007.
Regards,
Kar Poh
Software Engineer
Manufacturing Solutions Division
Autodesk, Inc.
wrote in message news:5784230@discussion.autodesk.com...
Hi,
I have developed a VC++ application which converts the Mechanical desktop
files into Step/DXF files. The application works fine with MDT2004 but has
been broken when trying to work with MDT2007.
The problem is the call to the function CoCreateInstance fails with hr =
NOINTERFACE for the code snippet mentioned below:
AutoCAD::IAcadApplication* AcadApp=NULL;
CLSID clsID;
CLSIDFromProgID(L"AutoCAD.Application.16", &clsID);
hr = CoCreateInstance(clsID, NULL, CLSCTX_LOCAL_SERVER,
__uuidof(AutoCAD::IAcadApplication), reinterpret_cast(&AcadApp));
if(!AcadApp)
{
//Failed to create MDT object so could not proceed.
//returning with failure
hr = E_FAIL;
}
I have tried the following to resolve the problem.
1) I used the CLSID i.e. "AutoCAD.Application.17" for MDT2007 and build the
application using the MDT2007 acax17enu.tlb. The application worked with
MDT2007, but fails to work with MDT2004 (even after using appropriate CLSID
"AutoCAD.Application.16").
2) Calling CoCreateInstance twice i.e. Call for MDT2007(using its CLSID and
hardcoded IAcadApplication interface id) and if it failed then Call for
MDT2004(using its CLSID and hardcoded IAcadApplication interface id). But
the application gives a runtime "COM Surrogate Error" message.
I want the same application to work with both MDT2004 and MDT 2007. Please
help me or provide me information regarding how to resolve this problem.
Thanks in Advance.