lanhaiou 发表于 2006-8-24 11:17:00

请教大虾们~~如何将一个多边形用矩形外接?

<DIV style="PADDING-RIGHT: 0px; MARGIN-TOP: 10px; FONT-SIZE: 9pt; OVERFLOW-X: hidden; WIDTH: 97%; WORD-BREAK: break-all; TEXT-INDENT: 24px; LINE-HEIGHT: normal; HEIGHT: 200px; WORD-WRAP: break-word" onload="this.style.overflowX='auto';">
<P>在autocad中的一个多边形图形,想把它用矩形外接,框起来.</P>
<P>我对objectarx还不很熟悉,不清楚有那些方法实现</P>
<P>有没有直接操作的函数?</P>
<P>要不然就先读多边形的每个顶点,经过判断后用直线化一个矩形?</P>
<P>帮我讲讲可能实现的思路好吗?谢谢~~~~~~~~~~~~!!</P><IMG src="http://www.cadhelp.com.cn/bbs/Skins/Default/emot/em01.gif" onload="<b>javascript</b> :if(this.width>500)this.style.width=500;" align=middle border=0><IMG src="http://www.cadhelp.com.cn/bbs/Skins/Default/emot/em01.gif" onload="<b>javascript</b> :if(this.width>500)this.style.width=500;" align=middle border=0></DIV>

HuaiYu 发表于 2006-8-24 21:42:00

<P>用 getGeomExtents 得到实体的外围框后再添加一个轻多段线就可以吧...</P>
<P>void test()<BR>{<BR>&nbsp;ads_name en;<BR>&nbsp;ads_point pt;<BR>&nbsp;if(acedEntSel("\nSpecify a object:",en,pt)!=RTNORM)<BR>&nbsp;&nbsp;return;<BR>&nbsp;AcDbObjectId eId;<BR>&nbsp;acdbGetObjectId(eId,en);<BR>&nbsp;AcDbEntity *pEnt;<BR>&nbsp;acdbOpenAcDbEntity(pEnt,eId,AcDb::kForRead);<BR>&nbsp;AcDbExtents exts;<BR>&nbsp;if(pEnt-&gt;getGeomExtents(exts)!=Acad::eOk)<BR>&nbsp;{<BR>&nbsp;&nbsp;acutPrintf("\n**Error on get the extents point...");<BR>&nbsp;&nbsp;pEnt-&gt;close();<BR>&nbsp;&nbsp;return;<BR>&nbsp;}<BR>&nbsp;acutPrintf("\nThe maxPoint=%0.4f,%0.4f",exts.maxPoint(),exts.maxPoint());<BR>&nbsp;acutPrintf("\nThe minPoint=%0.4f,%0.4f",exts.minPoint(),exts.minPoint());<BR>&nbsp;pEnt-&gt;close();<BR>&nbsp;<BR>&nbsp;//&nbsp;will be add a polyline to the ModelSpace<BR>&nbsp;//&nbsp;the vertex point will be add to the ptArray<BR>&nbsp;AcGePoint3dArray ptArray;<BR>&nbsp;ptArray.append(exts.minPoint());<BR>&nbsp;AcGePoint3d ptTemp;<BR>&nbsp;ptTemp=exts.maxPoint();<BR>&nbsp;ptTemp=exts.minPoint();<BR>&nbsp;ptTemp=exts.minPoint();<BR>&nbsp;ptArray.append(ptTemp);<BR>&nbsp;ptArray.append(exts.maxPoint());<BR>&nbsp;ptTemp=exts.minPoint();<BR>&nbsp;ptTemp=exts.maxPoint();<BR>&nbsp;ptTemp=exts.minPoint();<BR>&nbsp;ptArray.append(ptTemp);</P>
<P>&nbsp;AcDb2dPolyline *pNewLine=new AcDb2dPolyline(AcDb::k2dSimplePoly,ptArray,0.0,Adesk::kTrue);<BR>&nbsp;pNewLine-&gt;setColorIndex(1);</P>
<P>&nbsp;AcDbBlockTable *pBlockTable;<BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getSymbolTable(pBlockTable,AcDb::kForRead);<BR>&nbsp;AcDbBlockTableRecord *pMS;<BR>&nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE,pMS,AcDb::kForWrite);<BR>&nbsp;pBlockTable-&gt;close();<BR>&nbsp;pMS-&gt;appendAcDbEntity(eId,pNewLine);<BR>&nbsp;pNewLine-&gt;close();<BR>&nbsp;pMS-&gt;close();<BR>}</P>

lanhaiou 发表于 2006-8-25 11:28:00

<P>哇塞~~~~~~~</P>
<P>大虾</P>
<P>谢谢你啊~~!!!</P>
页: [1]
查看完整版本: 请教大虾们~~如何将一个多边形用矩形外接?