利用COM在ARX中下面代码AutoCAD2008中始终创建空白文件失败?
<p>AutoCAD2008中始终创建空白文件失败。谁能知诉我错在哪里?</p><p>// 创建一张新图纸<br/> LPDISPATCH pDispatch = acedGetAcadWinApp()->GetIDispatch(TRUE);<br/> IAcadApplication *acadApp = NULL;<br/> HRESULT hr = S_OK;<br/> hr = pDispatch->QueryInterface(IID_IAcadApplication, (LPVOID*)&acadApp);<br/> if (FAILED(hr))<br/> return;<br/> IAcadDocuments* pDocs;<br/> acadApp->get_Documents(&pDocs);<br/> IAcadDocument* pacadDoc;</p><p> VARIANT varTemplate;<br/> ::VariantInit(&varTemplate); <br/> varTemplate.vt = VT_BSTR;<br/> varTemplate.bstrVal = _bstr_t(g_sPath/*Arx文件路径*/) + _bstr_t("Template\\acadiso.dwt");<br/> ads_printf(varTemplate.bstrVal);<br/> hr = pDocs->Add(varTemplate, &pacadDoc); // ???这句代码执行返回结果失败,不能创建空白的图形文件</p><p>/* pDocs->Add(vtMissing, &pacadDoc); // 在AutoCAD2000中正常执行代码*/</p><p> if (FAILED(hr))<br/> {<br/> ads_printf(_T("创建空白的图形文件失败。\n"));<br/> return;<br/> }</p> 参考如下:<br/>void OpenDwg( void *pData)<br/>{<br/> AcApDocument* pDoc = acDocManager->curDocument();<br/> if (acDocManager->isApplicationContext()) <br/> acDocManager->appContextOpenDocument((const TCHAR *)pData);<br/> else<br/> acutPrintf(L"\nUNABLE TO FIND NEW.DWG!\n");<br/>}<br/><br/>// This is command 'OpenTemplate'<br/>void OpenTemplate()<br/>{<br/> // 直接打开系统中存在的某个模板,如c:\\Template\\new.dwg<br/>static TCHAR pData[] = _T("c:\\Template\\new.dw");<br/>acDocManager->executeInApplicationContext(OpenDwg, (void *)pData);<br/>}
页:
[1]