回复
本帖最后由 作者 于 2005-12-2 23:39:32 编辑 <br /><br /> <P></P><P></P>
<P></P>
<P>暂无...</P> 用ARX开发程序中,要用acedCommand()函数调用AUTOCAD中的“OPEN”命令,具体应该怎么做?
acedCommand(RTSTR, "open", RTSTR, "My_Drawing", 0);
这样做却打不开是怎么回事,望版主赐教!
回复
Avoiding Problems with NEW and OPENTo avoid loss of synchronization between the AutoCAD and ARX communication interface, do not pass acedCommand() or acedCmd() NEW or OPEN. Instead, pass a script that executes NEW and OPEN, answers the prompts, and calls a function in the ARX application to return control to the ARX application.
考虑一下: AcApDocManager Class,或用Insert命令.
<BR> //取得ARX模块路径<BR> TCHAR appFullPath;<BR> int len = GetModuleFileName(_hdllInstance, appFullPath, MAX_PATH);
CString strGridFullPath = appFullPath;<BR> strGridFullPath = strGridFullPath.Left(strGridFullPath.ReverseFind('\\')) + "<A href="file://Data//grid_500.dwg" target="_blank" >\\Data\\grid_500.dwg</A>";
TCHAR fullpath;<BR> <BR> if (acedFindFile(strGridFullPath, fullpath) == RTNORM) { <BR> resbuf *rb;<BR> if((rb = acutBuildList( RTSTR, "_insert",<BR> RTSTR, strGridFullPath,<BR> RTSTR, strInsPt,<BR> RTSHORT, 1,<BR> RTSHORT, 1,<BR> RTSHORT, 0,<BR> RTNONE)) != NULL)<BR> {<BR> if(acedCmd(rb) == RTNORM)<BR> {}<BR> else<BR> {}<BR> if(rb != NULL)<BR> {<BR> acutRelRb(rb);<BR> }<BR> }<BR> }<BR> else<BR> acutPrintf("\n Could not find grid_500.dwg file!"); 版主真是个好人!
如果中国程序员都向你这样热心,那就好了!
何愁中国软件不能腾飞!
回复
本帖最后由 作者 于 2005-12-2 23:41:12 编辑 <br /><br /> 呀,好高兴.共同提高吧.<P></P> 像起动界面这类的事情,以前从未想到过,因为都是产品一开始经理就定好的了,现在有这位好同志给了出来,才算是明白其道理,要是有一天也要做类似的事情,就不至于到处找了。真是好21世纪的雷锋!值得歌颂!
点滴
本帖最后由 作者 于 2004-9-23 22:45:19 编辑 <br /><br /> 14. 如何加载一个菜单文件?IAcadMenuGroups *mnuGrps = NULL;<BR> //...<BR> mnuGrps->Load(BSTR MenuFileName, VARIANT BaseMenu, IAcadMenuGroup **pMenuGroup);
// MenuFileName是自定义的菜单文件, BaseMenu是指什么呢?
方法:<BR> CString mac = "(COMMAND \"_MENULOAD\" \"acad_map.mnu\")"; <BR> if (acDocManager->curDocument()) {<BR> acedPostCommand( mac );<BR> mac = "(menucmd \"P10=+ACAD_MAP.地形图缩编\")";
//如果P10不存在,则新载入的菜单加到当前菜单最后面<BR> acedPostCommand( mac );<BR> }
15. upgradeOpen()函数用法:<BR> //...<BR> acdbGetObjectId(plineId, ename);<BR> AcDbEntity *pEntity;<BR> acdbOpenAcDbEntity(pEntity, plineId, AcDb::kForRead);<BR> //...<BR> AcDbPolyline *pLWPline = (AcDbPolyline*)pEntity; // 现在pLWPline处于打开状态<BR> //如果要修改pLWPline的属性,必须以写的方式打开<BR> pLWPline->upgradeOpen();<BR> pLWPline->setElevation(0.0);<BR> pLWPline->close();
注意,如果在使用upgradeOpen()之前,关闭了对象,将导致错误. 如<BR> pEntity->close(); //或 pLWPline->close();<BR> //...<BR> pLWPline->upgradeOpen();<BR> pLWPline->setElevation(0.0); // INTERNAL ERROR: <A href="mailto:!dbobji.cpp@6159" target="_blank" >!dbobji.cpp@6159</A>: eNotOpenForWrite<BR> pLWPline->close();
16. 如果一个对象已经删除,它的ID为objId,以下代码:<BR> AcDbEntity *pEntity;<BR> acdbOpenAcDbEntity(pEntity, objId, AcDb::kForRead);<BR> 结果pEntity为NULL.<BR> if (pEntity == NULL)<BR> acedAlert("NULL");<BR> if (pEntity)<BR> acedAlert("Exist");<BR> else<BR> acedAlert("None Exist");<BR> if (pEntity->isErased() == Adesk::kTrue) <BR> // 执行将出错,其实的确也没有什么疑义,本来pEntity就不曾成功指向任何实体,当然也就没有是否被Erased的判断了; <BR> // 是不是如果pEntity曾经指向过实体对象,该对象被删除之后,就可以用这一句来判断了呢? // 而判断该实体是否已经被删除,下面的代码可以:<BR> If (objId.isErased() != true)<BR> acedAlert("Exist");
17. 如何得到一个块(AcDbBlockReference)的名字?<BR> 用参考块实体的blockTableRecord()方法返回一个该block reference引用的AcDbBlockTableRecord的object ID.<BR> 打开AcDbBlockTableRecord,用getName(const char* &pName)获得块名.<BR> //...<BR> AcDbBlockReference *pBlkRef = (AcDbBlockReference*)pEnt;<BR> AcDbObjectId pBlockTableRecordId;<BR> pBlockTableRecordId = pBlkRef->blockTableRecord();<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> char* blkName;<BR> if (Acad::eOk == acdbOpenObject(pBlockTableRecord, pBlockTableRecordId, AcDb::kForRead))<BR> {<BR> pBlockTableRecord->getName(blkName);<BR> pBlockTableRecord->close();<BR> }
另一麻烦的方法:<BR> //...<BR> AcDbBlockReference *pBlkRef = (AcDbBlockReference*)pEnt;<BR> char* blkName;<BR> ads_name ssEntName;<BR> struct resbuf *rbSSEnt;<BR> struct resbuf *rbTrav;<BR> int rc;<BR> CString strBlkName = "";<BR> acdbGetAdsName(ssEntName, pBlkRef->objectId());<BR> rbSSEnt = acdbEntGet(ssEntName);<BR> rbTrav = rbSSEnt;<BR> while (rbTrav) {<BR> switch (rbTrav->restype)<BR> {<BR> case 2:<BR> strBlkName = rbTrav->resval.rstring;<BR> }<BR> rbTrav = rbTrav->rbnext;<BR> }//while
回复
点滴:17. VC.NET2002下调试ARX程序方法:<BR> (1) 编译arx程序,在需要调试的位置设置断点;<BR> (2) 在VC.NET环境下启动(F5)程序,出现窗口<BR> ["无符号化信息 - acad.exe并不包含调试信息.(未加载任何符号.)<BR> 如果仍要调试,请单击'确定'.]<BR> (3) 点击'确定'启动一个AutoCAD的进程,<BR> 在该进程中加载编译的arx程序,进行调试.
组实体操作
<BR>// 选择一个组实体,获得组名,删除组<BR>static void EraseGroup(void)<BR>{<BR> ads_name ent;<BR> AcDbObjectId objId;<BR> int rc;<BR> ads_point pt;rc = acedEntSel("\nPlease select an Group Entity: ", ent, pt);<BR> if (rc != RTNORM) {<BR> return;<BR> }<BR> acdbGetObjectId(objId, ent);<BR> AcDbObjectPointer<AcDbEntity>pEnt(objId, AcDb::kForRead);<BR> CString sGrpName;
AcDbVoidPtrArray *pReactors;<BR> void *pSomething;<BR> AcDbObjectId persObjId;<BR> pReactors = pEnt->reactors();
if (pReactors != NULL)<BR> {<BR> for (int i = 0; i < pReactors->length(); i++)<BR> {<BR> pSomething = pReactors->at(i);<BR> // Is it a persistent reactor?<BR> //<BR> if (acdbIsPersistentReactor(pSomething)) {<BR> persObjId = acdbPersistentReactorObjectId( pSomething );<BR> acutPrintf("\n\nPersistent reactor found.");<BR> if(pEnt.openStatus() == Acad::eOk)<BR> pEnt->close();<BR> AcDbObjectPointer<AcDbGroup>pGroup(persObjId, AcDb::kForWrite);<BR> sGrpName = pGroup->name();<BR> acedAlert(sGrpName);<BR> pGroup->erase();<BR> }<BR> }// for<BR> }
return;<BR>}
// 通过组名删除组实体<BR>static void EraseGroup(const char * pGroupName)<BR>{<BR> AcDbDictionary *pGroupDict;<BR> AcDbObjectId pGroupId;
acdbHostApplicationServices()->workingDatabase()->getGroupDictionary(pGroupDict, AcDb::kForWrite);
if (pGroupDict->getAt(pGroupName,pGroupId) == Acad::eOk)<BR> {<BR> AcDbObjectPointer <AcDbGroup> pGroup(pGroupId, AcDb::kForWrite);
pGroup->erase();<BR> pGroupDict->remove(pGroupId);<BR> pGroupDict->close();<BR> pGroup->close();<BR> }<BR> pGroupDict->close();
return;<BR>} 奇怪,我也用的是VC++.net 2002,但是不知为什么,就是不能调试,F5启动ACAD2004进程的时候,跳出ACAD错误的信息,怪怪的,有人遇到过这样的情况吗?我还以为是2004不能调试呢