明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2876|回复: 4

通过选择实体AcDbObjectId,怎么样得到AcDbBlockTableRecord的Id呀

[复制链接]
发表于 2007-12-24 11:43 | 显示全部楼层 |阅读模式

通过选择实体AcDbObjectId,怎么样得到AcDbBlockTableRecord的Id呀;

困扰了好几天了;

发表于 2007-12-24 13:27 | 显示全部楼层

是一般实体所在的BlockTableRecord还是块定义的BlockTableRecord

实体所在BlockTableRecord,打开实体AcDbEnitity::ownerId()

块定义:AcDbBlockReference::blockTableRecord()

 楼主| 发表于 2007-12-25 14:25 | 显示全部楼层

我用的是第一种;一般实体所在BlockTableRecord,现在还要用Id来打开Record;

acdbOpenObjectId()这个能实现吗?

 楼主| 发表于 2007-12-25 14:43 | 显示全部楼层

上一贴中的那个没有Id;

问一下各位,这样写能改变记录中的属性吗?

acdbOpenObject(pRec,RecId,AcDb::kForRead);
 if(pRec->hasAttributeDefinitions())
 {
  AcDbBlockTableRecordIterator *pIter;
  pRec->newIterator(pIter);
  AcDbEntity *pEnt;
  for(pIter->start();!pIter->done();pIter->step())
  {
   pIter->getEntity(pEnt,AcDb::kForRead);
   //acdbOpenObject(pEnt,blkDefId,AcDb::kForWrite);
   //检查是否是属性定义
   AcDbAttributeDefinition *pAttDef;
   pAttDef=AcDbAttributeDefinition::cast(pEnt);
   if(pAttDef!=NULL)
   {
    //pAttDef->setTag(Data);
    
    //创建一个新的属性对象
    AcDbAttribute *pAtt=new AcDbAttribute();
    //从属性定义获得属性对象的属性特性;
    pAtt->setPropertiesFrom(pAttDef);
    //设置属性对象的其它特性;
    pAtt->setInvisible(pAttDef->isInvisible());
    AcGePoint3d ptBase=pAttDef->position();
    ptBase+=pBlkRef->position().asVector();
    pAtt->setPosition(pAttDef->position());
    pAtt->setHeight(pAttDef->height());
    pAtt->setRotation(pAttDef->rotation());
    //获得属性对象的Tag、Prompt和TextString;
    char *pStr;
    pStr=pAttDef->tag();
    pAtt->setTag("123456789");

    pAtt->setTextString("Yuan");

    //向块参照追加属性对象;
    pBlkRef->appendAttribute(pAtt);
    pAtt->close();
   }
   pEnt->close();
  }
  delete(pIter);
 }
 pRec->close();

发表于 2018-6-13 13:23 | 显示全部楼层
学习ActiveX 的小白表示无助中
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-3-29 03:05 , Processed in 0.155939 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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