zoukankan      html  css  js  c++  java
  • ObjectARX学习笔记(三十)---如何克隆实体clone(),getTransformedCopy()

    <pre name="code" class="cpp">AcDbDatabase *pDataBase = NULL;
    pDataBase = acdbCurDwg(); //根据需要传入不同AcDbDatabase 就可以做到不同dwg克隆实体

    Acad::ErrorStatus es = Acad::eOk;

    //
    AcDbBlockTable *pBlockTable = NULL;
    es = pDataBase->getBlockTable(pBlockTable, AcDb::kForRead); //得到块表指针
    if (Acad::eOk != es)
    return false;

    AcDbBlockTableRecord *pBlockTableRecord = NULL;
    es = pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite); //得到块表记录指针
    if (Acad::eOk != es)
    return false;

    pBlockTable->close();
    pBlockTable = NULL;

    AcDbBlockTableRecordIterator *pBlockIter = NULL;
    es = pBlockTableRecord->newIterator(pBlockIter);
    if (Acad::eOk != es)
    return false;
    AcDbEntity *pEntity = NULL;
    AcGeMatrix3d xform;
    xform.setToTranslation(AcGeVector3d(100,500,0));
    AcDbObjectId objTmpId = AcDbObjectId::kNull;
    for (pBlockIter->start(); !pBlockIter->done(); pBlockIter->step())
    {
    pBlockIter->getEntityId(objTmpId);
    AcDbObjectPointer<AcDbEntity> pEnt(objTmpId, AcDb::kForWrite);
    if (pEnt.openStatus() == Acad::eOk)
    {

    //pEntity = AcDbEntity::cast(pEnt->clone());//克隆不移动
    pEnt->getTransformedCopy(xform,(AcDbEntity*&)pEntity); //克隆移动实体
    pEntity->setColorIndex(1);
    }

    }

    pBlockTableRecord->appendAcDbEntity(objTmpId,pEntity);
    pEntity->close();
    pBlockTableRecord->close();
    pBlockTableRecord = NULL;

    if (pBlockIter != NULL)
    {
    delete pBlockIter;
    pBlockIter = NULL;
    }
    return true;
     

  • 相关阅读:
    省市县 三级 四级联动Javascript JQ 插件PCASClass.js
    【转】提高PHP性能的53个技巧
    Windows下Wamp装不上Memcache扩展
    Weui 微信网站开发样式插件使用教程
    div高度自适应填充剩余部分
    Storm简介
    Spark简介
    MapReduce的输入输出
    MapReduce 2简介
    Hadoop的I/O操作
  • 原文地址:https://www.cnblogs.com/mjgw/p/12392794.html
Copyright © 2011-2022 走看看