用多边形区域选择方式构造选择集的问题
请教斑竹:构造选择集的时候,如果用CP或F构造选择集的时候,需要构造一个点链表。在知道链表的个数的前提下;可以这样做:
pt1 pt2 pt3 分别赋值后,然后调用 pointlist=acutBulidList(RTPOINT,pt1,RTPOINT,pt2,……,0)函数构造链表
然后建立选择集 acedSSGet("CP",pointlist,NULL,NULL,ssname);
如果让用户选择的方式,构造多边形,事先不知道多少点,请问怎么建链表??
谢谢
试验不成功
本帖最后由 作者 于 2004-9-24 23:00:06 编辑 <br /><br /> 帮我找找原因:// ----- asdkDynRb._DYNRB command (do not rename)<BR> static void asdkDynRb_DYNRB(void)<BR> {<BR> // Add your code for command asdkDynRb._DYNRB here<BR> ads_point pick, lastpt;<BR> int nRet;<BR> ads_name ss;<BR> struct resbuf *ptList = NULL;<BR> struct resbuf *rbTrav ;<BR> struct resbuf *newRb;<BR> Adesk::Boolean keepPicking = Adesk::kTrue;<BR> Adesk::Boolean firstPick = Adesk::kTrue;
while (keepPicking)<BR> {<BR> if (firstPick)<BR> {<BR> nRet = acedGetPoint(NULL, "\nPick first point: ", pick);<BR> firstPick = Adesk::kFalse;
newRb = acutNewRb(RTPOINT);<BR> newRb->resval.rpoint = pick;<BR> newRb->resval.rpoint = pick;<BR> newRb->resval.rpoint = pick;<BR> ptList = newRb;<BR> rbTrav = newRb;<BR> //if (newRb)<BR> // acutRelRb(newRb);<BR> }<BR> else<BR> {<BR> acdbPointSet(pick, lastpt);<BR> nRet = acedGetPoint(pick, "\nPick next point - for exit: ", pick);<BR> acedGrDraw(lastpt, pick, 1, 0);
newRb = acutNewRb(RTPOINT);<BR> newRb->resval.rpoint = pick;<BR> newRb->resval.rpoint = pick;<BR> newRb->resval.rpoint = pick;<BR> rbTrav->rbnext = newRb;<BR> rbTrav = rbTrav->rbnext;<BR> //if (newRb)<BR> // acutRelRb(newRb);<BR> }<BR> if (nRet != RTNORM)<BR> {<BR> keepPicking = Adesk::kFalse;<BR> break;<BR> }
}// while<BR> <BR> // Clear out the grdraw drawn vectors<BR> //acedRedraw(NULL, 1);
//newRb = acutNewRb(RTNONE);<BR> ////rbTrav = rbTrav->rbnext;<BR> ////rbTrav = newRb;<BR> //rbTrav->rbnext = newRb;<BR> //rbTrav = rbTrav->rbnext;<BR> rbTrav->rbnext = NULL;<BR> //rbTrav = ptList;
nRet = acedSSGet("CP", ptList, NULL, NULL, ss);<BR> if (nRet == RTNORM)<BR> {<BR> long nEnts;<BR> nRet = acedSSLength(ss, &nEnts);<BR> if (nRet == RTNORM) {<BR> CString str;<BR> str.Format("%d", nEnts);<BR> acedAlert(str);<BR> for (int i = 0; i < nEnts; i++) {<BR> ads_name eName;<BR> acedSSName(ss, i, eName);<BR> AcDbObjectId id;<BR> acdbGetObjectId(id, eName);<BR> AcDbEntity *pEnt;<BR> acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead);<BR> pEnt->highlight();<BR> pEnt->close();<BR> }<BR> }<BR> }<BR> else<BR> acedAlert("选择失败");<BR> } 有没有可能是需要RT3DPOINT类型的节点呢?只是猜测,没有试哦 版主 辛苦了。
我刚开始的做法也是像斑竹这样做的。
我再想想
回复
共同考虑吧,一定会有答案的.For AutoCAD2005源程序,试试看:
谢谢,
我用的是AutoCAD2000,2005加载不了,说一下思想就可以了
回复
找到上面的一段代码,加到你的程序中,找找问题所在!写一个从点数组构建缓冲区链表的程序即可。
(1)仅对数组中第一个点构建链表;
(2)将后面的点逐个添加到链表中。(如果你对数据结构比较了解,这个问题就轻而易举了。)