zoukankan      html  css  js  c++  java
  • ObjectARX2010 学习笔记004:复制多段线点生成新多段线

    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;
    }
    
  • 相关阅读:
    yii框架_用户登录
    判断变量是否定义
    ajax小结
    yii框架_1
    yii框架_1_简单模型搭建与应用
    Greedy Gift Givers
    C# 音量控制 静音 等
    Fidelity Job Opportunities
    SPSiteDataQuery
    eBooks on html javascript & css
  • 原文地址:https://www.cnblogs.com/swtool/p/3815776.html
Copyright © 2011-2022 走看看