CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

将组添加到组字典

2024-5-18 18:25| 发布者: admin| 查看: 82| 评论: 0|原作者: admin|来自: AutoCAD

将组添加到组字典

下面的代码在 and 函数中创建的线和圆之外创建一个组 (),并将该组放入 GROUP 字典中。直线和圆的对象 ID 将传递到函数中。请注意 GROUP 字典是如何打开写入、修改和显式关闭的。pGroupcreateLine()createCircle()

void
createGroup(AcDbObjectIdArray& objIds, char* pGroupName)
{
    AcDbGroup *pGroup = new AcDbGroup(pGroupName);
    // Put the group in the group dictionary which resides
    // in the named object dictionary.
    //
    AcDbDictionary *pGroupDict;
    acdbHostApplicationServices()->workingDatabase()
        ->getGroupDictionary(pGroupDict, AcDb::kForWrite);
    AcDbObjectId pGroupId;
    pGroupDict->setAt(pGroupName, pGroup, pGroupId);
    pGroupDict->close();
    // Now that the group has been added, it has an ObjectID.
    // This is important since the group will become a persistent
    // reactor for the added entities...
    for (int i = 0; i < objIds.length(); i++) {
        pGroup->append(objIds[i]);
        }
    pGroup->close();
}

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 13:15

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部