多段线换方向
昨天看了有人用LISP写了一个多段线换向的程序,现在我也写了一个,时间仓促,请大家多多指教。第一次发帖void PostToModelSpace(AcDbEntity *pEnt)
{
AcDbBlockTable *pBlkTbl;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl,AcDb::kForRead);
AcDbBlockTableRecord *pBlkTblRcd;
pBlkTbl->getAt(ACDB_MODEL_SPACE,pBlkTblRcd,AcDb::kForWrite);
pBlkTbl->close();
AcDbObjectId entId;
pBlkTblRcd->appendAcDbEntity(entId,pEnt);
pEnt->close();
pBlkTblRcd->close();
}
static void XsdkArxProject3HUAN(void)
{
// Add your code for command XsdkArxProject3.HUAN here
ads_name ss,s1;
struct resbuf *rb = acutBuildList(RTDXF0,L"LWPOLYLINE",RTNONE);
if (acedSSGet(NULL,NULL,NULL,rb,ss)!=RTNORM)
{
return;
}
long len;
if (RTNORM==acedSSLength(ss,&len))
{
for (int i = 0; i < len; i++)
{
acedSSName(ss,i,s1);
AcDbObjectId id;
acdbGetObjectId(id,s1);
AcDbPolyline *pPline ;
acdbOpenObject(pPline,id,AcDb::kForWrite);
AcGePoint2dArrayptArray;
for (int j = 0; j < pPline->numVerts(); j++)
{
AcGePoint2d p2d; pPline->getPointAt(j,p2d);
ptArray.append(p2d);
}
ptArray = ptArray.reverse();
AcDbPolyline *pNewPoly = new AcDbPolyline(ptArray.length());
for (int k = 0; k < ptArray.length(); k++)
{
AcGePoint2d p2d1 = ptArray.at(k);
pNewPoly->addVertexAt(k,p2d1);
}
pNewPoly->setPropertiesFrom(pPline);
pNewPoly->setXData(pPline->xData());
PostToModelSpace(pNewPoly);
pPline->erase();
pPline->close();
}
}
acedSSFree(ss);
acutRelRb(rb);
}
兄弟 你帖子发错地方了 这里是ObjectARX板块 我记得AcdbPolyline中有一个函数是可以直接获得线上所有点的,还有可以不新建一个多线,可以先获得多线段所有的点,然后把点集顺序颠倒,然后可以在原线上用setPointAt(int,Acgepoint2d)直接反向,这样是不是能更优化点呢? Curve::reverse(); 不错的程序,谢楼主分享啊。 如果有弧这个程序不对的
页:
[1]