Announcements
IMPORTANT. Forum to be archived in several phases. You can no longer submit new questions - but can only answer existing threads until Oct 17th 2016. Please read this message for details
Mechanical Desktop (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

My VC++ application which works with MDT2004 does not work with MDT2007

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
357 Views, 2 Replies

My VC++ application which works with MDT2004 does not work with MDT2007

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.
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

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.
Message 3 of 3
bigdaaddy
in reply to: Anonymous

Can you tell me, where did you find this application. We spend a lot of time
to do DXF and STEP.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report