明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: 王咣生

ObjectARX工作日志

    [复制链接]
 楼主| 发表于 2004-9-3 13:19 | 显示全部楼层

回复

本帖最后由 作者 于 2005-12-2 23:39:32 编辑

暂无...

发表于 2004-9-6 10:36 | 显示全部楼层
用ARX开发程序中,要用acedCommand()函数调用AUTOCAD中的“OPEN”命令,具体应该怎么做?


acedCommand(RTSTR, "open", RTSTR, "My_Drawing",        0);


这样做却打不开是怎么回事,望版主赐教!
 楼主| 发表于 2004-9-6 19:25 | 显示全部楼层

回复

Avoiding Problems with NEW and OPEN To 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命令.
//取得ARX模块路径
TCHAR appFullPath[MAX_PATH];
int len = GetModuleFileName(_hdllInstance, appFullPath, MAX_PATH); CString strGridFullPath = appFullPath;
strGridFullPath = strGridFullPath.Left(strGridFullPath.ReverseFind('\\')) + "\\Data\\grid_500.dwg"; TCHAR fullpath[512];

if (acedFindFile(strGridFullPath, fullpath) == RTNORM) {
resbuf *rb;
if((rb = acutBuildList( RTSTR, "_insert",
RTSTR, strGridFullPath,
RTSTR, strInsPt,
RTSHORT, 1,
RTSHORT, 1,
RTSHORT, 0,
RTNONE)) != NULL)
{
if(acedCmd(rb) == RTNORM)
{}
else
{}
if(rb != NULL)
{
acutRelRb(rb);
}
}
}
else
acutPrintf("\n Could not find grid_500.dwg file!");
发表于 2004-9-15 09:48 | 显示全部楼层
版主真是个好人!


如果中国程序员都向你这样热心,那就好了!


何愁中国软件不能腾飞!
 楼主| 发表于 2004-9-15 22:24 | 显示全部楼层

回复

本帖最后由 作者 于 2005-12-2 23:41:12 编辑

呀,好高兴.共同提高吧.

发表于 2004-9-16 17:52 | 显示全部楼层
像起动界面这类的事情,以前从未想到过,因为都是产品一开始经理就定好的了,现在有这位好同志给了出来,才算是明白其道理,要是有一天也要做类似的事情,就不至于到处找了。真是好21世纪的雷锋!值得歌颂!
 楼主| 发表于 2004-9-22 11:51 | 显示全部楼层

点滴

本帖最后由 作者 于 2004-9-23 22:45:19 编辑

14. 如何加载一个菜单文件? IAcadMenuGroups *mnuGrps = NULL;
//...
mnuGrps->Load(BSTR MenuFileName, VARIANT BaseMenu, IAcadMenuGroup **pMenuGroup); // MenuFileName是自定义的菜单文件, BaseMenu是指什么呢? 方法:
CString mac = "(COMMAND \"_MENULOAD\" \"acad_map.mnu\")";
if (acDocManager->curDocument()) {
acedPostCommand( mac );
mac = "(menucmd \"P10=+ACAD_MAP.地形图缩编\")"; //如果P10不存在,则新载入的菜单加到当前菜单最后面
acedPostCommand( mac );
} 15. upgradeOpen()函数用法:
//...
acdbGetObjectId(plineId, ename);
AcDbEntity *pEntity;
acdbOpenAcDbEntity(pEntity, plineId, AcDb::kForRead);
//...
AcDbPolyline *pLWPline = (AcDbPolyline*)pEntity; // 现在pLWPline处于打开状态
//如果要修改pLWPline的属性,必须以写的方式打开
pLWPline->upgradeOpen();
pLWPline->setElevation(0.0);
pLWPline->close(); 注意,如果在使用upgradeOpen()之前,关闭了对象,将导致错误. 如
pEntity->close(); //或 pLWPline->close();
//...
pLWPline->upgradeOpen();
pLWPline->setElevation(0.0); // INTERNAL ERROR: !dbobji.cpp@6159: eNotOpenForWrite
pLWPline->close(); 16. 如果一个对象已经删除,它的ID为objId,以下代码:
AcDbEntity *pEntity;
acdbOpenAcDbEntity(pEntity, objId, AcDb::kForRead);
结果pEntity为NULL.
if (pEntity == NULL)
acedAlert("NULL");
if (pEntity)
acedAlert("Exist");
else
acedAlert("None Exist");
if (pEntity->isErased() == Adesk::kTrue)
// 执行将出错,其实的确也没有什么疑义,本来pEntity就不曾成功指向任何实体,当然也就没有是否被Erased的判断了;
// 是不是如果pEntity曾经指向过实体对象,该对象被删除之后,就可以用这一句来判断了呢? // 而判断该实体是否已经被删除,下面的代码可以:
If (objId.isErased() != true)
acedAlert("Exist"); 17. 如何得到一个块(AcDbBlockReference)的名字?
用参考块实体的blockTableRecord()方法返回一个该block reference引用的AcDbBlockTableRecord的object ID.
打开AcDbBlockTableRecord,用getName(const char* &pName)获得块名.
//...
AcDbBlockReference *pBlkRef = (AcDbBlockReference*)pEnt;
AcDbObjectId pBlockTableRecordId;
pBlockTableRecordId = pBlkRef->blockTableRecord();
AcDbBlockTableRecord *pBlockTableRecord;
char* blkName;
if (Acad::eOk == acdbOpenObject(pBlockTableRecord, pBlockTableRecordId, AcDb::kForRead))
{
pBlockTableRecord->getName(blkName);
pBlockTableRecord->close();
} 另一麻烦的方法:
//...
AcDbBlockReference *pBlkRef = (AcDbBlockReference*)pEnt;
char* blkName;
ads_name ssEntName;
struct resbuf *rbSSEnt;
struct resbuf *rbTrav;
int rc;
CString strBlkName = "";
acdbGetAdsName(ssEntName, pBlkRef->objectId());
rbSSEnt = acdbEntGet(ssEntName);
rbTrav = rbSSEnt;
while (rbTrav) {
switch (rbTrav->restype)
{
case 2:
strBlkName = rbTrav->resval.rstring;
}
rbTrav = rbTrav->rbnext;
}//while
 楼主| 发表于 2004-9-24 22:42 | 显示全部楼层

回复

点滴: 17. VC.NET2002下调试ARX程序方法:
(1) 编译arx程序,在需要调试的位置设置断点;
(2) 在VC.NET环境下启动(F5)程序,出现窗口
["无符号化信息 - acad.exe并不包含调试信息.(未加载任何符号.)
如果仍要调试,请单击'确定'.]
(3) 点击'确定'启动一个AutoCAD的进程,
在该进程中加载编译的arx程序,进行调试.
 楼主| 发表于 2004-10-3 00:50 | 显示全部楼层

组实体操作

<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&lt;AcDbEntity&gt;pEnt(objId, AcDb::kForRead);<BR>        CString sGrpName;


        AcDbVoidPtrArray        *pReactors;<BR>        void                                *pSomething;<BR>        AcDbObjectId                 persObjId;<BR>        pReactors = pEnt-&gt;reactors();


        if (pReactors != NULL)<BR>        {<BR>                for (int i = 0; i &lt; pReactors-&gt;length(); i++)<BR>                {<BR>                        pSomething = pReactors-&gt;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-&gt;close();<BR>                                AcDbObjectPointer&lt;AcDbGroup&gt;pGroup(persObjId, AcDb::kForWrite);<BR>                                sGrpName = pGroup-&gt;name();<BR>                                acedAlert(sGrpName);<BR>                                pGroup-&gt;erase();<BR>                        }<BR>                }// for<BR>        }


        return;<BR>}


// 通过组名删除组实体<BR>static void EraseGroup(const char * pGroupName)<BR>{<BR>        AcDbDictionary *pGroupDict;<BR>        AcDbObjectId pGroupId;


        acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getGroupDictionary(pGroupDict, AcDb::kForWrite);


        if (pGroupDict-&gt;getAt(pGroupName,pGroupId)         == Acad::eOk)<BR>        {<BR>                AcDbObjectPointer &lt;AcDbGroup&gt; pGroup(pGroupId, AcDb::kForWrite);


                pGroup-&gt;erase();<BR>                pGroupDict-&gt;remove(pGroupId);<BR>                pGroupDict-&gt;close();<BR>                pGroup-&gt;close();<BR>        }<BR>        pGroupDict-&gt;close();


        return;<BR>}
发表于 2004-10-7 16:21 | 显示全部楼层
奇怪,我也用的是VC++.net 2002,但是不知为什么,就是不能调试,F5启动ACAD2004进程的时候,跳出ACAD错误的信息,怪怪的,有人遇到过这样的情况吗?我还以为是2004不能调试呢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-24 06:56 , Processed in 0.265218 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表