标签:des style blog color width os
static void swtArxProject5plcopy(void) { // Add your code for command swtArxProject5.plcopy here //定义对象名和点 ads_name ename;ads_point pt; //如果没有选择到实体 if(acedEntSel(NULL,ename,pt)!=RTNORM) { return; } //定义并获取ID AcDbObjectId id; acdbGetObjectId(id,ename); //定义并获取实体 AcDbEntity *pEnt; acdbOpenObject(pEnt,id,AcDb::kForRead); //定义点集 AcGePoint2dArray pts; //判断是否是多段线 if(pEnt->isKindOf(AcDbPolyline::desc())) { //如果是,定义多段线 AcDbPolyline *pPline=AcDbPolyline::cast(pEnt); //点数量 int num=pPline->numVerts(); //在点中循环 for (int i=0;i<num;i++) { AcGePoint2d pt; //取得每个点 pPline->getPointAt(i,pt); //将点加入到点集 pts.append(pt); } pPline->close(); } //关闭实体 pEnt->close(); //创建多段线 CreatePolyline(pts,1.0); }
AcDbObjectId CreatePolyline(AcGePoint2dArray pts,double width) { int numVertex =pts.length(); AcDbPolyline *pPoly=new AcDbPolyline(numVertex); for (int i=0;i<numVertex;i++) { pPoly->addVertexAt(i,pts.at(i),0,width,width); } AcDbObjectId polyId; pPoly->setColorIndex(1); polyId=PostToModelSpace(pPoly); pPoly->close(); return polyId; }
ObjectARX2010 学习笔记004:复制多段线点生成新多段线,布布扣,bubuko.com
ObjectARX2010 学习笔记004:复制多段线点生成新多段线
标签:des style blog color width os
原文地址:http://www.cnblogs.com/swtool/p/3815776.html