|
//检测AutoCAD是否已经运行
CODE:
void Autocadtest()
{
// TODO: Add your control notification handler code here
IAcadApplication m_autocad;
IAcadDocuments m_acaddocs;
IAcadDocument m_acaddoc;
IAcadModelSpace m_acadmodel;
LPDISPATCH pDisp;
LPUNKNOWN pUnk;
CLSID clsid;
BeginWaitCursor();
::CLSIDFromProgID(L"AutoCAD.Application",&clsid);
if(::GetActiveObject(clsid,NULL,&pUnk)==S_OK)
{
VERIFY(pUnk->QueryInterface(IID_IDispatch,(void**) &pDisp)==S_OK);
m_autocad.AttachDispatch(pDisp);
pUnk->Release();
}
else
{
if(!m_autocad.CreateDispatch("AutoCAD.Application"))
{
AfxMessageBox("Autocad program not found\n");
exit(1);
}
}
m_autocad.SetVisible(true);
m_acaddocs.AttachDispatch(m_autocad.GetDocuments(),true);
m_acaddoc.AttachDispatch(m_acaddocs.Add(vtMissing),true);
m_acadmodel.AttachDispatch(m_acaddoc.GetModelSpace(),true);
m_acadmodel.AddCircle(pVal,100);
m_acadmodel.ReleaseDispatch();
m_acaddoc.ReleaseDispatch();
m_acaddocs.ReleaseDispatch();
m_autocad.ReleaseDispatch();
} |
|