找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2066|回复: 0

[其他] 利用ARX从AUTOLISP创建匿名组

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-16 20:44:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Create an anonymous group from Visual LISP with help from ARX



问题:
DevNote TS36234 describes how to create an anonymous group from VBA, with the
help of an ARX application that was supplied.  Is it possible to call this ARX
application directly from Lisp?  Is it also possible to return the Object ID
of the newly-created group to the Lisp function, as well?

解答:

The attached ARX project is slightly different from the one available in DevNote
(TS36234), in this example acedDefun() is used to define the command
acdbAddAnonGrpRet2Lsp() as an external Lisp function.  It is further modified
to return a list, containing the new group's ObjectID, to the external Lisp
function, as well.

  1. // ObjectARX defined commands


  2. #include "StdAfx.h"
  3. #include "StdArx.h"


  4. // This is command 'ACDBADDANONGRPRET2LSP'
  5. int acdbAddAnonGrpRet2Lsp()
  6. {
  7.    // TODO: Implement the command
  8.    resbuf *pArg =acedGetArgs () ;


  9.    struct resbuf *startRb = NULL;
  10.    AcDbGroup *pGroup = new AcDbGroup();
  11.    AcDbObjectId grpId;
  12.    AcDbDictionary *pGroupDict;
  13.    Acad::ErrorStatus es;
  14.    AcApDocument *curDoc;


  15.    //get the group dictionary
  16.    AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
  17.    if (Acad::eOk == (es = acDocManager->lockDocument(curDoc=acDocManager->curDocument())))
  18.       es = pDb->getGroupDictionary(pGroupDict,AcDb::kForWrite);


  19.    if (es != Acad::eOk)
  20.       return es;


  21.    //make an anonymous entry
  22.    if ((es = pGroupDict->setAt("*", pGroup, grpId)) == Acad::eOk) {
  23.       //retrieve its name char *pNam;
  24.       pGroup->close();
  25.    }


  26.    // create a resbuf with our ObjectID in it
  27.    struct resbuf *newRb = acutBuildList (RTLONG, grpId, RTNONE);
  28.    // if ok
  29.    if (newRb != NULL) {
  30.       // if this is the first time we've done this
  31.       if (startRb == NULL) {
  32.          // then set this as the start
  33.          startRb = newRb;
  34.       }
  35.       // otherwise add it to the end of our list
  36.       else {
  37.          // create a pointer to the beginning of our resbuf list
  38.          struct resbuf *ptr = startRb;
  39.          // find the end of our list
  40.          while (ptr->rbnext != NULL)
  41.             ptr = ptr->rbnext;


  42.          // now attach our newly create resbuf to the end
  43.          ptr->rbnext = newRb;
  44.       }
  45.    }


  46.    pGroupDict->close();
  47.    acDocManager->unlockDocument(curDoc);


  48.    acedRetList(startRb);
  49.    acutRelRb(startRb);
  50.    return (RTNORM);
  51. }


For the most part, the following Lisp code is a direct translation of the VBA
code from the DevNote (TS36234):

下面是LISP代码:
游客,本帖隐藏的内容需要积分高于 30 才可浏览,您当前积分为 0

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-22 13:50 , Processed in 0.381194 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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