NO

Author Topic: IntelliCAD COM  (Read 2551 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1891
IntelliCAD COM
« on: December 23, 2010, 02:09:53 pm »
Can anyone test this code with Intellicad, progeCAD, etc.
This code doesn't work with progeCAD 2009 Smart! as line is not created.
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ole2.h>

#define COBJMACROS
#include "ICADAuto.h" // from ICadAuto.dll

#pragma lib "ole32.lib"
#pragma lib "oleaut32.lib"

char *szAppName = "ICadTest";

//CLSID const CLSID_Application = {0x8011C111,0x7E36,0x11D1,0xBC,0x5A,0x00,0x60,0x08,0x96,0x08,0xA4};
CLSID const IID_IcadApplication = {0x8011C101,0x7E36,0x11D1,0xBC,0x5A,0x00,0x60,0x08,0x96,0x08,0xA4};

//CLSID const CLSID_Application = {0x06200386,0xF06F,0x41F8,0x92,0x0A,0xA1,0xCB,0x30,0x1B,0x7E,0xEC}; // progeCAD 2009

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
HRESULT hr;
CLSID clsid;
IIcadApplication *pICad = NULL;
IIcadDocuments *pICadDocs = NULL;
IIcadDocument *pICadDoc = NULL;
IIcadModelSpace *pModelSpace = NULL;
IIcadLibrary *pICadLib = NULL;
IIcadPoint *pPt1 = NULL;
IIcadPoint *pPt2 = NULL;
IIcadLine *pLine = NULL;

CoInitialize(NULL);
//hr = CLSIDFromProgID(L"Icad.Application.1", &clsid); // progeCAD LT 2006
//hr = CLSIDFromProgID(L"Icad.Application.9.0", &clsid); // progeCAD Smart! 2009
hr = CLSIDFromProgID(L"Icad.Application", &clsid);
hr = CoCreateInstance(&clsid, NULL, CLSCTX_ALL, &IID_IcadApplication, (void **)&pICad);

if (pICad)
{
IIcadApplication_put_Visible(pICad, -1);
//IIcadApplication_get_ActiveDocument(pICad, &pICadDoc);
IIcadApplication_get_Documents(pICad, &pICadDocs);
if (pICadDocs)
{
IIcadDocuments_Add(pICadDocs, &pICadDoc);
IIcadApplication_get_Library(pICad, &pICadLib);
if (pICadDoc && pICadLib)
{
IIcadLibrary_CreatePoint(pICadLib, 0, 0, 0, &pPt1);
IIcadLibrary_CreatePoint(pICadLib, 100, 100, 0, &pPt2);
IIcadDocument_get_ModelSpace(pICadDoc, &pModelSpace);
if (pModelSpace && pPt1 && pPt2)
{
IIcadEntities_AddLine((IIcadEntities *)pModelSpace, pPt1, pPt2, &pLine);
if (!pLine) MessageBox(0, "Line not created ?", 0, MB_OK);
//IIcadEntity_Update((IIcadEntity*)pLine);
}
}
IIcadDocument_Regen(pICadDoc, 0);
}
IIcadApplication_Release((IDispatch *)pICad);
}
else
{
MessageBox(0, "No ICAD.Application ?", szAppName, MB_OK);
}
CoUninitialize();
return 0;
}
Any ideas ?

EDIT: It needs header file for that version of ICadAuto.dll
« Last Edit: June 23, 2016, 05:03:48 pm by TimoVJL »
May the source be with you