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