bopugs 发表于 2009-4-21 07:40:00

[求助]如何把图纸中所有的文字提取出来

刚学ObjectARX,现在想实现把当前文档中包含的所有文字提取出来,请各位前辈高人指点。

dll 发表于 2009-4-21 15:31:00

<p>最简单的就是遍历数据库然后判断类型是否是文字了,</p><p>isKindOf( AcdbText::desc() )</p>

bopugs 发表于 2009-4-22 21:31:00

谢谢dll,不知道有没有这样的例子

nogirlfriend 发表于 2009-4-23 18:12:00

<p>给你一段代码吧 希望对你有启发</p><p>AcDbDatabase* pDb = acdbHostApplicationServices()-&gt;workingDatabase();<br/>&nbsp;if (pDb == NULL)<br/>&nbsp;{<br/>&nbsp;&nbsp;acutPrintf("\n当前无活动的图形!");<br/>&nbsp;&nbsp;return false;<br/>&nbsp;}</p><p>&nbsp;AcDbBlockTable *pBlockTable;<br/>&nbsp;if (pDb-&gt;getBlockTable(pBlockTable, AcDb::kForRead) != Acad::eOk)<br/>&nbsp;{<br/>&nbsp;&nbsp;acutPrintf("\n打开块表失败!");<br/>&nbsp;&nbsp;return false;<br/>&nbsp;}</p><p>&nbsp;AcDbBlockTableRecord *pBlockRec;<br/>&nbsp;if (pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockRec, AcDb::kForRead)!= Acad::eOk)<br/>&nbsp;{<br/>&nbsp;&nbsp;acutPrintf("打开模型空间失败!");<br/>&nbsp;&nbsp;pBlockTable-&gt;close();<br/>&nbsp;&nbsp;return false;<br/>&nbsp;}<br/>&nbsp;pBlockTable-&gt;close();</p><p>&nbsp;AcDbBlockTableRecordIterator* pIterator,*pIter;&nbsp;<br/>&nbsp;pBlockRec-&gt;newIterator(pIterator,true,false);<br/>&nbsp;pBlockRec-&gt;newIterator(pIter,true,false);<br/>&nbsp;if( pIterator-&gt;done())<br/>&nbsp;{<br/>&nbsp;&nbsp;acutPrintf("\n当前图形无数据。");<br/>&nbsp;&nbsp;pBlockRec-&gt;close();<br/>&nbsp;&nbsp;delete pIterator;<br/>&nbsp;&nbsp;return false;<br/>&nbsp;}</p><p>&nbsp;AcDbEntity*&nbsp;pEnt;<br/>&nbsp;for(; !pIterator-&gt;done(); pIterator-&gt;step(true,false))<br/>&nbsp;{ <br/>&nbsp;&nbsp;if(pIterator-&gt;getEntity(pEnt, AcDb::kForRead,true)!=Acad::eOk)<br/>&nbsp;&nbsp;&nbsp;continue;&nbsp;</p><p>&nbsp;&nbsp;if(pEnt-&gt;isKindOf(AcdbText::desc() true)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;AcDbObjectId eId;<br/>&nbsp;&nbsp;&nbsp;eId=pEnt-&gt;objectId();</p><p>&nbsp;&nbsp;&nbsp;ids.append(eId);<br/>&nbsp;&nbsp;}</p><p>&nbsp;&nbsp;pEnt-&gt;close();<br/>&nbsp;}<br/>&nbsp;pBlockRec-&gt;close();<br/>&nbsp;delete pIterator;</p>

bopugs 发表于 2009-4-23 20:13:00

太感谢<font face="Verdana" color="#61b713"><strong>nogirlfriend</strong><font color="#000000">了。</font></font>
页: [1]
查看完整版本: [求助]如何把图纸中所有的文字提取出来