找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 383|回复: 0

[ARX程序]:请高手帮帮小弟修改一下这个遍历选择集的程序,自觉这程序太烦琐!!

[复制链接]
发表于 2004-6-30 17:26:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
void getArrCenter{

        char tmp[10];  //过渡变量
        struct resbuf eb1;        //过滤用的结果缓冲区链表变量
        ads_name getCircle; //选择集名
        ads_name temEnt;        //实体名       
        ads_real inputRadius = 0; //过滤的圆半径       
        ads_point startPoint,endPoint; //框选时的起点及终点
        AcGePoint3d arrCenter;        //圆心坐标数组变量

        acedGetReal("\nPROMPT::Input want to filter out the circle Radius: ", &inputRadius);
        if(inputRadius == 0) //判断用户是否有输入圆半径
        {
                acdbFail("\nERROR::Input radius is Null or Zero!");
                return;
        }

//设置过虑链表
        eb1.restype = 0;
        strcpy(tmp, "CIRCLE");
        eb1.resval.rstring = tmp;
       
        eb1.restype = 40;
        eb1.resval.rreal = inputRadius;
        eb1.rbnext = NULL;

        acedGetPoint(NULL,"\nSelection the start Point:",startPoint);//取得框选起点

        acedInitGet(RSG_DASH,NULL); //设置框选线为虚线

        acedGetCorner(startPoint,"\nSelection the second Point:",endPoint);        //画框取得第二点


        if(acedSSGet("W",startPoint,endPoint,&eb1,getCircle) == RTNORM)        //创建选择集
        {
                acutPrintf("\nPROMPT::Create the selection set Succeed!");
        }
        else
        {
                acdbFail("\nERROR::Create the selection set Fail!");
                return;       
        }
       
        long lenLast;        //存放选择集实体数量的变量
        AcDbEntity *pEnt;        //实体指针变量
        AcDbCircle *pCirc;        //圆指针变量
       
        if(acedSSLength(getCircle, &lenLast) != RTNORM)        //取得选择集的实体数量
        {
                acdbFail("\nERROR::Get the selection set length Fail!");
                return;
        }

//循环遍历选择集开始
for(k=0, k<lenLast, k++)
{       
                AcDbObjectId pEntId;        //对象ID
                acedSSName(getCircle, i, temEnt);        //取得实体

                acdbGetObjectId(pEntId, temEnt);//取得对应ID

                acdbOpenObject(pEnt, pEntId, AcDb::kForRead);        //把实体指针指向该实体

                pCirc = AcDbCircle::cast(pEnt);        //赋给圆指针
                arrCenter.append(pCirc->center());//追加圆心坐标到圆心数组
               
        }
       
        pCirc->close();
        pEnt->close();
        acedSSFree(getCircle);

}

程序功能:遍历整个选择集并取得圆心的坐标,但我个人觉这这样写太烦琐了,应该可以简掉不少语句,请前辈们指点一下!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-21 19:49 , Processed in 0.351789 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表