luckstar 发表于 2007-12-24 11:43:00

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

<p>通过选择实体AcDbObjectId,怎么样得到AcDbBlockTableRecord的Id呀; </p><p>困扰了好几天了;</p>

fpiw 发表于 2007-12-24 13:27:00

<p>是一般实体所在的BlockTableRecord还是块定义的BlockTableRecord</p><p>实体所在BlockTableRecord,打开实体AcDbEnitity::ownerId()</p><p>块定义:AcDbBlockReference::blockTableRecord()</p>

luckstar 发表于 2007-12-25 14:25:00

<p>我用的是第一种;一般实体所在BlockTableRecord,现在还要用Id来打开Record;</p><p>acdbOpenObjectId()这个能实现吗?</p>

luckstar 发表于 2007-12-25 14:43:00

<p>上一贴中的那个没有Id;</p><p>问一下各位,这样写能改变记录中的属性吗?</p><p>acdbOpenObject(pRec,RecId,AcDb::kForRead);<br/>&nbsp;if(pRec-&gt;hasAttributeDefinitions())<br/>&nbsp;{<br/>&nbsp;&nbsp;AcDbBlockTableRecordIterator *pIter;<br/>&nbsp;&nbsp;pRec-&gt;newIterator(pIter);<br/>&nbsp;&nbsp;AcDbEntity *pEnt;<br/>&nbsp;&nbsp;for(pIter-&gt;start();!pIter-&gt;done();pIter-&gt;step())<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;pIter-&gt;getEntity(pEnt,AcDb::kForRead);<br/>&nbsp;&nbsp;&nbsp;//acdbOpenObject(pEnt,blkDefId,AcDb::kForWrite);<br/>&nbsp;&nbsp;&nbsp;//检查是否是属性定义<br/>&nbsp;&nbsp;&nbsp;AcDbAttributeDefinition *pAttDef;<br/>&nbsp;&nbsp;&nbsp;pAttDef=AcDbAttributeDefinition::cast(pEnt);<br/>&nbsp;&nbsp;&nbsp;if(pAttDef!=NULL)<br/>&nbsp;&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;//pAttDef-&gt;setTag(Data);<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;//创建一个新的属性对象<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcDbAttribute *pAtt=new AcDbAttribute();<br/>&nbsp;&nbsp;&nbsp;&nbsp;//从属性定义获得属性对象的属性特性;<br/>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setPropertiesFrom(pAttDef);<br/>&nbsp;&nbsp;&nbsp;&nbsp;//设置属性对象的其它特性;<br/>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setInvisible(pAttDef-&gt;isInvisible());<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcGePoint3d ptBase=pAttDef-&gt;position();<br/>&nbsp;&nbsp;&nbsp;&nbsp;ptBase+=pBlkRef-&gt;position().asVector();<br/>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setPosition(pAttDef-&gt;position());<br/>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setHeight(pAttDef-&gt;height());<br/>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setRotation(pAttDef-&gt;rotation());<br/>&nbsp;&nbsp;&nbsp;&nbsp;//获得属性对象的Tag、Prompt和TextString;<br/>&nbsp;&nbsp;&nbsp;&nbsp;char *pStr;<br/>&nbsp;&nbsp;&nbsp;&nbsp;pStr=pAttDef-&gt;tag();<br/>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setTag("123456789");</p><p>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setTextString("Yuan");</p><p>&nbsp;&nbsp;&nbsp;&nbsp;//向块参照追加属性对象;<br/>&nbsp;&nbsp;&nbsp;&nbsp;pBlkRef-&gt;appendAttribute(pAtt);<br/>&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;close();<br/>&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;&nbsp;pEnt-&gt;close();<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;delete(pIter);<br/>&nbsp;}<br/>&nbsp;pRec-&gt;close();</p>

一只鸟243aZ 发表于 2018-6-13 13:23:08

学习ActiveX 的小白表示无助中
页: [1]
查看完整版本: 通过选择实体AcDbObjectId,怎么样得到AcDbBlockTableRecord的Id呀