[求助]求助编译代码
<pre>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);</pre><pre> 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));</pre><pre> pRecord->appendAcDbEntity(pPolyExt);<br/> pRecord->appendAcDbEntity(pVLn);<br/> pRecord->appendAcDbEntity(pHLn);<br/> pPolyExt->close();<br/> pVLn->close();<br/> pHLn->close();<br/> pRecord->close();<br/> }</pre>
页:
[1]