高手帮忙,由块名得到块中属性的值
给定一个块名,得到该块中所有属性的值,请大家帮忙啊。谢谢 怎么没人帮我啊5555555555 help me master 快来帮帮我吧,急reply
使用AcDbBlockReferenceIterator帮你找个例子,wait... To <A name=5452><FONT color=#990000><B>王咣生</B></FONT></A>
找到例子了吗?
谢谢 怎么还没消息啊。我急啊
reply
本帖最后由 作者 于 2005-1-25 17:22:15 编辑 <br /><br /> <PRE class=prog_in_0> static void ExtractAttributes()<BR> {<BR> ads_name ename;<BR> ads_point pt;<BR> <BR> if(ads_entsel("\nSelect an block: ", ename, pt) != RTNORM)<BR> {<BR> ads_printf("\nError selecting entity."); <BR> return; <BR> }<BR> <BR> AcDbObjectId eId; <BR> acdbGetObjectId(eId, ename);<BR> AcDbEntity* pEnt = NULL;</PRE><PRE class=prog_in_0> if (acdbOpenObject(pEnt, eId , AcDb::kForRead) != Acad::eOk)<BR> { <BR> ads_printf("\nError opening entity.");<BR> if(pEnt)<BR> pEnt->close();<BR> return;<BR> }<BR> <BR> if(pEnt->isA() != AcDbBlockReference::desc())<BR> {<BR> ads_printf("\nMust select a block insert.");<BR> pEnt->close();<BR> return;<BR> }</PRE><PRE class=prog_in_0> AcDbBlockReference *pBlkRef = AcDbBlockReference::cast(pEnt);<BR> AcDbAttribute *pAtt = NULL;<BR> AcDbObjectIterator *pAttIter = pBlkRef->attributeIterator();</PRE><PRE class=prog_in_0> _TCHAR tagName, strValue;</PRE><PRE class=prog_in_0> for (pAttIter->start(); !pAttIter->done(); pAttIter->step())<BR> {<BR> acdbOpenObject(pAtt, pAttIter->objectId(), AcDb::kForRead);<BR> // get the tag string<BR> _tcscpy(tagName, pAtt->tag());<BR> ads_printf("\nBlock Insert Attribute tag is: %s", tagName);<BR> _tcscpy(strValue, pAtt->textString());<BR> ads_printf("\nBlock Insert Attribute string value is: %s", <BR> <BR> strValue);<BR> pAtt->close();<BR> }<BR> delete pAttIter;<BR> pBlkRef->close();<BR> }</PRE>
页:
[1]