天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 66|回复: 0

arx 从块定义创建一个INSERT

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]AcDbObjectId createInsertForBlock (AcDbObjectId blockId, AcGePoint3d basePoint,
                   AcGeScale3d scaleFactor, double rotationAng,
                   AcGeVector3d vector, AcDbObjectId ownerRefId,
                   AcDbObjectId blockRefLayId)
{
    AcDbDatabase *pDB;
    AcDbBlockReference *pBlkRef;
    AcDbBlockTable *pBlockTable;
    AcDbBlockTableRecord *pBlockTableRecord;
    AcDbObjectId newEntId;
    AcDbBlockTableRecord *pBlockDef;
    AcDbBlockTableRecordIterator *pIterator;
    AcDbBlockReference *pOriginalRef;
    AcDbObjectIterator *pIterRef;   
    AcDbEntity *pEnt;
    AcDbAttributeDefinition *pAttdef;

    pDB = acdbHostApplicationServices()->workingDatabase();

    pBlkRef = new AcDbBlockReference;   
    pBlkRef->setBlockTableRecord(blockId);
    pBlkRef->setNormal(vector);
    pBlkRef->setPosition(basePoint);
    pBlkRef->setScaleFactors(scaleFactor);
    pBlkRef->setRotation(rotationAng);
    pBlkRef->setLayer(blockRefLayId, Adesk::kFalse);


    pDB->getBlockTable(pBlockTable, AcDb::kForRead);


    pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);
    pBlockTable->close();     

    pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef);
    pBlockTableRecord->close();

    acdbOpenObject(pBlockDef, blockId, AcDb::kForRead);

    pBlockDef->newIterator(pIterator);   

    //____iterating original block ref for attributes
    acdbOpenObject(pOriginalRef,ownerRefId,AcDb::kForRead);
    pIterRef =pOriginalRef->attributeIterator ();   
    pOriginalRef->close();


    for(pIterator->start(); !pIterator->done(); pIterator->step())
    {
        pIterator->getEntity(pEnt, AcDb::kForRead);
        pAttdef = AcDbAttributeDefinition::cast (pEnt);
        if (pAttdef != NULL && !pAttdef->isConstant())
        {   
            //____iteration of original block ref continues...
            AcDbObject *pObj;
            AcDbObjectId ida;
            AcDbAttribute *pAtt;
            AcDbObjectId attId;

            ida = pIterRef->objectId();
            acdbOpenObject(pObj, ida, AcDb::kForRead);
            pAtt = AcDbAttribute::cast(pObj->clone());
            pObj->close();

            pAtt->setTextString("XXX");
            pBlkRef->appendAttribute(attId, pAtt);
            pAtt->close();
            pIterRef->step();
        }

        pEnt->close();
    }

    delete pIterator;   
    delete pIterRef;
    pBlockDef->close();
    pBlkRef->close();

    return newEntId;
}[/code]

 

 

 

 

arx 从块定义创建一个INSERT
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 10:27 , Processed in 0.145358 second(s), 28 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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