julianwoo 发表于 2010-1-30 10:25:00

[求助]请帮忙把这段代码转成*.ARX

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

trisinker 发表于 2010-1-30 15:48:00

<p>貌似可以在ARX下运行的,如果真的要转,把ads函数改为arx对应的函数吧。</p><p></p>

iostream7 发表于 2010-4-29 15:56:00

<p>&nbsp; ads_name ents;<br/>&nbsp; if(acedSSGet(NULL,NULL,NULL,NULL,ents) == RTNORM)<br/>&nbsp; {<br/>&nbsp;&nbsp;&nbsp; AcDbExtents ext;<br/>&nbsp;&nbsp;&nbsp; long nLen = 0;<br/>&nbsp;&nbsp;&nbsp; acedSSLength(ents,&amp;nLen);</p><p>&nbsp;&nbsp;&nbsp; for ( long i = 0; i &lt; nLen; i++)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ads_name curEnt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acedSSName(ents,i,curEnt);</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDbObjectId curId;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(acdbGetObjectId(curId,curEnt) != Acad::eOk)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDbEntity * pEnt = NULL;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acdbOpenAcDbEntity(pEnt,curId,AcDb::kForRead);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (pEnt == NULL)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDbExtents curExt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pEnt-&gt;getGeomExtents(curExt);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ext.addExt(curExt);<br/>&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; acedSSFree(ents);<br/>&nbsp;&nbsp;&nbsp; AcDbDatabase * pDb = acdbCurDwg();<br/>&nbsp;&nbsp;&nbsp; if (pDb == NULL)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<br/>&nbsp;&nbsp;&nbsp; AcDbBlockTable * pBlock = NULL;<br/>&nbsp;&nbsp;&nbsp; pDb-&gt;getBlockTable(pBlock,AcDb::kForWrite);<br/>&nbsp;&nbsp;&nbsp; if (pBlock == NULL)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;</p><p>&nbsp;&nbsp;&nbsp; AcDbBlockTableRecord * pRecord = NULL;<br/>&nbsp;&nbsp;&nbsp; pBlock-&gt;getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);<br/>&nbsp;&nbsp;&nbsp; if (pRecord == NULL)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pBlock-&gt;close();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<br/>&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;&nbsp; pBlock-&gt;close();</p><p></p><p>// ...</p>
页: [1]
查看完整版本: [求助]请帮忙把这段代码转成*.ARX