明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: dipenghao

用多边形区域选择方式构造选择集的问题

  [复制链接]
发表于 2004-9-25 11:44:00 | 显示全部楼层

成功了

调试通过的代码: // ----- asdkDynRb._DYNRB command (do not rename)
static void asdkDynRb_DYNRB(void)
{
// Add your code for command asdkDynRb._DYNRB here
ads_point firstpt, pick, lastpt;
int nRet;
ads_name ss;
struct resbuf *ptList = NULL;
struct resbuf *rbTrav ;
struct resbuf *newRb;
Adesk::Boolean keepPicking = Adesk::kTrue;
Adesk::Boolean firstPick = Adesk::kTrue; while (keepPicking)
{
if (firstPick)
{
nRet = acedGetPoint(NULL, "\nPick first point: ", pick);
acdbPointSet(pick, firstpt);
firstPick = Adesk::kFalse; newRb = acutNewRb(RTPOINT);
newRb->resval.rpoint[0] = pick[0];
newRb->resval.rpoint[1] = pick[1];
newRb->resval.rpoint[2] = pick[2];
ptList = newRb;
rbTrav = newRb;
}
else
{
acdbPointSet(pick, lastpt);
nRet = acedGetPoint(pick, "\nPick next point - [ENTER] for exit: ", pick);

if (nRet != RTNORM)
{
acedGrDraw(lastpt, firstpt, 1, 0);
keepPicking = Adesk::kFalse;
break;
} acedGrDraw(lastpt, pick, 1, 0);
newRb = acutNewRb(RTPOINT);
newRb->resval.rpoint[0] = pick[0];
newRb->resval.rpoint[1] = pick[1];
newRb->resval.rpoint[2] = pick[2];
rbTrav->rbnext = newRb;
rbTrav = rbTrav->rbnext;

}
}// while

// Clear out the grdraw drawn vectors
//acedRedraw(NULL, 1); rbTrav->rbnext = NULL;
nRet = acedSSGet("CP", ptList, NULL, NULL, ss); if (nRet == RTNORM)
{
long nEnts;
nRet = acedSSLength(ss, &nEnts);
if (nRet == RTNORM) {
CString str;
str.Format("%d", nEnts);
acedAlert(str);
for (int i = 0; i < nEnts; i++) {
ads_name eName;
acedSSName(ss, i, eName);
AcDbObjectId id;
acdbGetObjectId(id, eName);
AcDbObjectPointer<AcDbEntity> ent (id, AcDb::kForRead);
if (ent.openStatus() == Acad::eOk) {
ent->highlight();
}
}
}
}
else
acedAlert("选择失败"); if (ss)
acedSSFree(ss);
}

本帖子中包含更多资源

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

x
发表于 2004-9-25 11:49:00 | 显示全部楼层
newRb = acutNewRb(RTPOINT);
newRb->resval.rpoint[0] = pick[0];
newRb->resval.rpoint[1] = pick[1];
newRb->resval.rpoint[2] = pick[2];
rbTrav->rbnext = newRb;
改成 rbTrav->rbnext = acutBuildList(RTPOINT, pick, RTNONE); 试试看。 不行的话你把跟踪的结果告诉我。
发表于 2004-9-25 11:54:00 | 显示全部楼层

回复

问题并不在那儿: rbTrav->rbnext = NULL; 相当于 newRb = acutNewRb(RTNONE); 这与你的 rbTrav->rbnext = acutBuildList(RTPOINT, pick, RTNONE); 中的RTNONE可能是冲突的. 总之现在可以了, 感谢zfbj. 这样的讨论气氛挺好的.
发表于 2004-9-25 11:58:00 | 显示全部楼层

回复

按你说的我试试.
发表于 2004-9-25 11:58:00 | 显示全部楼层
不用客气,大家相互合作,互相提高吧。
发表于 2004-9-25 12:06:00 | 显示全部楼层

回复

试过了, rbTrav->rbnext = newRb;
//rbTrav->rbnext = acutBuildList(RTPOINT, pick, RTNONE); 两种写法都可以, //rbTrav->rbnext = NULL; 一句似乎也没起什么作用, 还是以前的建立链表代码有问题. 更改后的代码: // ----- asdkDynRb._DYNRB command (do not rename)
static void asdkDynRb_DYNRB(void)
{
// Add your code for command asdkDynRb._DYNRB here
ads_point firstpt, pick, lastpt;
int nRet;
ads_name ss;
struct resbuf *ptList = NULL;
struct resbuf *rbTrav ;
Adesk::Boolean keepPicking = Adesk::kTrue;
Adesk::Boolean firstPick = Adesk::kTrue; while (keepPicking)
{
if (firstPick)
{
nRet = acedGetPoint(NULL, "\nPick first point: ", pick);
acdbPointSet(pick, firstpt);
firstPick = Adesk::kFalse; ptList = acutBuildList(RTPOINT, pick, RTNONE);
rbTrav = ptList;
}
else
{
acdbPointSet(pick, lastpt);
nRet = acedGetPoint(pick, "\nPick next point - [ENTER] for exit: ", pick);

if (nRet != RTNORM)
{
acedGrDraw(lastpt, firstpt, 1, 0);
keepPicking = Adesk::kFalse;
break;
} acedGrDraw(lastpt, pick, 1, 0); rbTrav->rbnext = acutBuildList(RTPOINT, pick, RTNONE);
rbTrav = rbTrav->rbnext;
}
}// while

// Clear out the grdraw drawn vectors
//acedRedraw(NULL, 1); nRet = acedSSGet("CP", ptList, NULL, NULL, ss); if (nRet == RTNORM)
{
long nEnts;
nRet = acedSSLength(ss, &nEnts);
if (nRet == RTNORM) {
CString str;
str.Format("%d", nEnts);
acedAlert(str);
for (int i = 0; i < nEnts; i++) {
ads_name eName;
acedSSName(ss, i, eName);
AcDbObjectId id;
acdbGetObjectId(id, eName);
AcDbObjectPointer<AcDbEntity> ent (id, AcDb::kForRead);
if (ent.openStatus() == Acad::eOk) {
ent->highlight();
}
}
}
}
else
acedAlert("选择失败"); if (ss)
acedSSFree(ss);
}

本帖子中包含更多资源

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

x
发表于 2004-9-25 13:29:00 | 显示全部楼层
newRb = acutNewRb(RTPOINT);
newRb->resval.rpoint[0] = pick[0];
newRb->resval.rpoint[1] = pick[1];
newRb->resval.rpoint[2] = pick[2];
rbTrav->rbnext = newRb;
rbTrav = rbTrav->rbnext;
为何不行??? 一定要这个么??rbTrav->rbnext = acutBuildList(RTPOINT, pick, RTNONE);
发表于 2004-9-25 16:15:00 | 显示全部楼层
仔细看看上面的贴子. newRb = acutNewRb(RTPOINT);
newRb->resval.rpoint[0] = pick[0];
newRb->resval.rpoint[1] = pick[1];
newRb->resval.rpoint[2] = pick[2];
rbTrav->rbnext = newRb;
rbTrav = rbTrav->rbnext; 也可以呀, rbTrav->rbnext = acutBuildList(RTPOINT, pick, RTNONE);这是zfbj后来给出的方法.
发表于 2004-9-27 08:44:00 | 显示全部楼层
你2楼的代码怎么通不过???


真奇怪!!
 楼主| 发表于 2004-9-27 16:06:00 | 显示全部楼层
多谢easypower
王咣生 zfbj 三位, 尤其是zfbj,不愧为超级版主 ,
,我现在正在做二次开发方面的,以后还请三位多多指教,给三位送花 呵呵
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 12:25 , Processed in 0.164381 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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