Mechanical Desktop

Mechanical Desktop

Reply
New Member
SunShine
Posts: 1
Registered: ‎11-22-2007
Message 1 of 3 (164 Views)

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

164 Views, 2 Replies
11-22-2007 10:36 PM
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.
*Kar Poh Tay \(Autodesk\)
Message 2 of 3 (163 Views)

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

11-25-2007 06:10 PM in reply to: SunShine
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.
Contributor
bigdaaddy
Posts: 13
Registered: ‎08-18-2007
Message 3 of 3 (163 Views)

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

11-28-2007 12:23 AM in reply to: SunShine
Can you tell me, where did you find this application. We spend a lot of time
to do DXF and STEP.
Announcements
Manufacturing Community
The Manufacturing Community provides additional access to tips, tutorials, blogs and networking with peers.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.