明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1754|回复: 3

利用ObjectDBX技术在当前图形中插入其他未打开图形中的图块

[复制链接]
发表于 2005-2-22 09:44:00 | 显示全部楼层 |阅读模式
张帆老师讲过在vba中的实现方式,不知在objectarx中怎么实现?
 楼主| 发表于 2005-2-23 11:56:00 | 显示全部楼层
怎么没人回答?
发表于 2005-2-23 13:39:00 | 显示全部楼层
readDwgFile(),取得实体ID,然后clone对象.
void
cloneSameOwnerObjects()
{
    // Step 1:  Obtain the set of objects to be cloned.
    ads_name sset;
    if (acedSSGet(NULL, NULL, NULL, NULL, sset) != RTNORM) {
        acutPrintf("\nNothing selected");
        return;
    }
    // Step 2: Add obtained object IDs to list of objects
    // to be cloned.
    long length;
    acedSSLength(sset, &length);
    AcDbObjectIdArray  objList;
    AcDbObjectId ownerId = AcDbObjectId::kNull;
    for (int i = 0; i < length; i++) {
        ads_name ent;
        acedSSName(sset, i, ent);
        AcDbObjectId objId;
        acdbGetObjectId(objId, ent);
        // Check to be sure this has the same owner as the first
        // object.
        //
        AcDbObject *pObj;
        acdbOpenObject(pObj, objId, AcDb::kForRead);
        if (pObj->ownerId() == ownerId)
            objList.append(objId);
        else if (i == 0) {
            ownerId = pObj->ownerId();
            objList.append(objId);
        }
        pObj->close();
    }
    acedSSFree(sset);
    // Step 3: Get the object ID of the desired owner for
    // the cloned objects.  We'll use model space for
    // this example.
    //
    AcDbBlockTable *pBlockTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForRead);
    AcDbObjectId  modelSpaceId;
    pBlockTable->getAt(ACDB_MODEL_SPACE, modelSpaceId);
    pBlockTable->close();
    // Step 4:  Create a new ID map.
    //
    AcDbIdMapping idMap;
    // Step 5: Call deepCloneObjects().
    //
    acdbHostApplicationServices()->workingDatabase()
        ->deepCloneObjects(objList, modelSpaceId, idMap);
    // Now we can go through the ID map and do whatever we'd
    // like to the original and/or clone objects.
    //
    // For this example, we'll print out the object IDs of
    // the new objects resulting from the cloning process.
    //
    AcDbIdMappingIter iter(idMap);
    for (iter.start(); !iter.done(); iter.next()) {
        AcDbIdPair idPair;
        iter.getMap(idPair);
        if (!idPair.isCloned())
            continue;
        acutPrintf("\nObjectId is: %Ld",
            idPair.value().asOldId());
    }
}
 楼主| 发表于 2005-2-23 16:12:00 | 显示全部楼层
谢谢,我先看看,学习学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-27 20:35 , Processed in 0.177467 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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