[求助]请帮忙把这段代码转成*.ARX
<p>ads_name ents;<br/> if(ads_ssget(NULL,NULL,NULL,NULL,ents) == RTNORM)<br/> {<br/> AcDbExtents ext;<br/> long nLen = 0;<br/> ads_sslength(ents,&nLen);<br/> long i = 0;<br/> for (; i < nLen; i++)<br/> {<br/> ads_name curEnt;<br/> ads_ssname(ents,i,curEnt);<br/> AcDbObjectId curId;<br/> if(acdbGetObjectId(curId,curEnt) != Acad::eOk)<br/> continue;<br/> AcDbEntity * pEnt = NULL;<br/> acdbOpenAcDbEntity(pEnt,curId,AcDb::kForRead);<br/> if (pEnt == NULL)<br/> continue;<br/> AcDbExtents curExt;<br/> pEnt->getGeomExtents(curExt);<br/> ext.addExt(curExt);<br/> }<br/> ads_ssfree(ents);<br/> AcDbDatabase * pDb = acdbCurDwg();<br/> if (pDb == NULL)<br/> return;<br/> AcDbBlockTable * pBlock = NULL;<br/> pDb->getBlockTable(pBlock,AcDb::kForWrite);<br/> if (pBlock == NULL)<br/> return;<br/> AcDbBlockTableRecord * pRecord = NULL;<br/> pBlock->getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);<br/> if (pRecord == NULL)<br/> {<br/> pBlock->close();<br/> return;<br/> }<br/> pBlock->close();<br/> <br/> //绘制矩形<br/> AcDbPolyline *pPolyExt = new AcDbPolyline;<br/> pPolyExt->addVertexAt(0,AcGePoint2d(ext.minPoint().x,ext.minPoint().y));<br/> pPolyExt->addVertexAt(1,AcGePoint2d(ext.minPoint().x,ext.maxPoint().y));<br/> pPolyExt->addVertexAt(2,AcGePoint2d(ext.maxPoint().x,ext.maxPoint().y));<br/> pPolyExt->addVertexAt(3,AcGePoint2d(ext.maxPoint().x,ext.minPoint().y));<br/> pPolyExt->setClosed(Adesk::kTrue);<br/> //绘制中心线<br/> AcDbLine * pVLn = new AcDbLine,* pHLn = new AcDbLine;<br/> pVLn->setStartPoint(AcGePoint3d((ext.minPoint().x+ext.maxPoint().x)*0.5,ext.minPoint().y,0));<br/> pVLn->setEndPoint(AcGePoint3d((ext.minPoint().x+ext.maxPoint().x)*0.5,ext.maxPoint().y,0));<br/> pHLn->setStartPoint(AcGePoint3d(ext.minPoint().x,(ext.minPoint().y+ext.maxPoint().y)*0.5,0));<br/> pHLn->setEndPoint(AcGePoint3d(ext.maxPoint().x,(ext.minPoint().y+ext.maxPoint().y)*0.5,0));<br/> pRecord->appendAcDbEntity(pPolyExt);<br/> pRecord->appendAcDbEntity(pVLn);<br/> pRecord->appendAcDbEntity(pHLn);<br/> pPolyExt->close();<br/> pVLn->close();<br/> pHLn->close();<br/> pRecord->close();<br/> }</p><p></p> <p>貌似可以在ARX下运行的,如果真的要转,把ads函数改为arx对应的函数吧。</p><p></p> <p> ads_name ents;<br/> if(acedSSGet(NULL,NULL,NULL,NULL,ents) == RTNORM)<br/> {<br/> AcDbExtents ext;<br/> long nLen = 0;<br/> acedSSLength(ents,&nLen);</p><p> for ( long i = 0; i < nLen; i++)<br/> {<br/> ads_name curEnt;<br/> acedSSName(ents,i,curEnt);</p><p> AcDbObjectId curId;<br/> if(acdbGetObjectId(curId,curEnt) != Acad::eOk)<br/> continue;</p><p> AcDbEntity * pEnt = NULL;<br/> acdbOpenAcDbEntity(pEnt,curId,AcDb::kForRead);<br/> if (pEnt == NULL)<br/> continue;</p><p> AcDbExtents curExt;<br/> pEnt->getGeomExtents(curExt);<br/> ext.addExt(curExt);<br/> }<br/> <br/> acedSSFree(ents);<br/> AcDbDatabase * pDb = acdbCurDwg();<br/> if (pDb == NULL)<br/> return 1;<br/> AcDbBlockTable * pBlock = NULL;<br/> pDb->getBlockTable(pBlock,AcDb::kForWrite);<br/> if (pBlock == NULL)<br/> return 1;</p><p> AcDbBlockTableRecord * pRecord = NULL;<br/> pBlock->getAt(ACDB_MODEL_SPACE,pRecord,AcDb::kForWrite);<br/> if (pRecord == NULL)<br/> {<br/> pBlock->close();<br/> return 1;<br/> }<br/> pBlock->close();</p><p></p><p>// ...</p>
页:
[1]