- 积分
- 47
- 明经币
- 个
- 注册时间
- 2015-8-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
昨天看了有人用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);
- AcGePoint2dArray ptArray;
- 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);
- }
|
|