julianwoo 发表于 2010-1-22 10:31:00

[求助]求助编译代码

<pre>ads_name ents;<br/>&nbsp;if(ads_ssget(NULL,NULL,NULL,NULL,ents) == RTNORM)<br/>&nbsp;{<br/>&nbsp;&nbsp;AcDbExtents ext;<br/>&nbsp;&nbsp;long nLen = 0;<br/>&nbsp;&nbsp;ads_sslength(ents,&amp;nLen);<br/>&nbsp;&nbsp;long i = 0;<br/>&nbsp;&nbsp;for (; i &lt; nLen; i++)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;ads_name curEnt;<br/>&nbsp;&nbsp;&nbsp;ads_ssname(ents,i,curEnt);<br/>&nbsp;&nbsp;&nbsp;AcDbObjectId curId;<br/>&nbsp;&nbsp;&nbsp;if(acdbGetObjectId(curId,curEnt) != Acad::eOk)<br/>&nbsp;&nbsp;&nbsp;&nbsp;continue;<br/>&nbsp;&nbsp;&nbsp;AcDbEntity * pEnt = NULL;<br/>&nbsp;&nbsp;&nbsp;acdbOpenAcDbEntity(pEnt,curId,AcDb::kForRead);<br/>&nbsp;&nbsp;&nbsp;if (pEnt == NULL)<br/>&nbsp;&nbsp;&nbsp;&nbsp;continue;<br/>&nbsp;&nbsp;&nbsp;AcDbExtents curExt;<br/>&nbsp;&nbsp;&nbsp;pEnt-&gt;getGeomExtents(curExt);<br/>&nbsp;&nbsp;&nbsp;ext.addExt(curExt);<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;ads_ssfree(ents);</pre><pre>&nbsp;&nbsp;AcDbDatabase * pDb = acdbCurDwg();<br/>&nbsp;&nbsp;if (pDb == NULL)<br/>&nbsp;&nbsp;&nbsp;return;<br/>&nbsp;&nbsp;AcDbBlockTable * pBlock = NULL;<br/>&nbsp;&nbsp;pDb-&gt;getBlockTable(pBlock,AcDb::kForWrite);<br/>&nbsp;&nbsp;if (pBlock == NULL)<br/>&nbsp;&nbsp;&nbsp;return;<br/>&nbsp;&nbsp;AcDbBlockTableRecord * pRecord = NULL;<br/>&nbsp;&nbsp;pBlock-&gt;getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);<br/>&nbsp;&nbsp;if (pRecord == NULL)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;pBlock-&gt;close();<br/>&nbsp;&nbsp;&nbsp;return;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;pBlock-&gt;close();<br/>&nbsp;<br/>&nbsp;&nbsp;//绘制矩形<br/>&nbsp;&nbsp;AcDbPolyline *pPolyExt = new AcDbPolyline;<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(0,AcGePoint2d(ext.minPoint().x,ext.minPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(1,AcGePoint2d(ext.minPoint().x,ext.maxPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(2,AcGePoint2d(ext.maxPoint().x,ext.maxPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;addVertexAt(3,AcGePoint2d(ext.maxPoint().x,ext.minPoint().y));<br/>&nbsp;&nbsp;pPolyExt-&gt;setClosed(Adesk::kTrue);<br/>&nbsp;&nbsp;//绘制中心线<br/>&nbsp;&nbsp;AcDbLine * pVLn = new AcDbLine,* pHLn = new AcDbLine;<br/>&nbsp;&nbsp;pVLn-&gt;setStartPoint(AcGePoint3d((ext.minPoint().x+ext.maxPoint().x)*0.5,ext.minPoint().y,0));<br/>&nbsp;&nbsp;pVLn-&gt;setEndPoint(AcGePoint3d((ext.minPoint().x+ext.maxPoint().x)*0.5,ext.maxPoint().y,0));<br/>&nbsp;&nbsp;pHLn-&gt;setStartPoint(AcGePoint3d(ext.minPoint().x,(ext.minPoint().y+ext.maxPoint().y)*0.5,0));<br/>&nbsp;&nbsp;pHLn-&gt;setEndPoint(AcGePoint3d(ext.maxPoint().x,(ext.minPoint().y+ext.maxPoint().y)*0.5,0));</pre><pre>&nbsp;&nbsp;pRecord-&gt;appendAcDbEntity(pPolyExt);<br/>&nbsp;&nbsp;pRecord-&gt;appendAcDbEntity(pVLn);<br/>&nbsp;&nbsp;pRecord-&gt;appendAcDbEntity(pHLn);<br/>&nbsp;&nbsp;pPolyExt-&gt;close();<br/>&nbsp;&nbsp;pVLn-&gt;close();<br/>&nbsp;&nbsp;pHLn-&gt;close();<br/>&nbsp;&nbsp;pRecord-&gt;close();<br/>&nbsp;}</pre>
页: [1]
查看完整版本: [求助]求助编译代码