anston 发表于 2007-3-15 10:33:00

[求助]如何通过点击直线获得两端点的坐标

本帖最后由 作者 于 2007-3-17 12:23:02 编辑 <br /><br /> <p>有许多不相连的任意线段<br/>目标:通过点击每条线段,来得到每条线段两端点的坐标。最好能区分线段的StartPoint和EndPoint</p><p>如何实现这一目标?</p><p>我现在的代码如下():<br/>float xco1, yco1, xco2, yco2;&nbsp; //xco1,yco1是直线起点的x,y坐标;xco2,yco2是直线终点的x,y坐标<br/>int LineNumCount=0;<br/>ads_name entres;<br/>ads_point ptres;<br/>acedGetInt("Please input the line number:",&amp;LineNumCount); //输入待选取的直线总数<br/>for(int i=0;i&lt;LineNumCount;i++)<br/>{<br/>&nbsp;&nbsp;&nbsp;&nbsp; if(acedEntSel("\nPlease select a line:",entres,ptres)==RTNORM)<br/>&nbsp;&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acutPrintf("\nPicking is OK!");</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDbObjectId Id1;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acdbGetObjectId(Id1, entres);&nbsp; //获得对象的ID<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acutPrintf("\nGetObjectId is OK!");</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDbObject *pObj;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acdbOpenAcDbObject(pObj, Id1, AcDb::kForRead, false); //根据ID打开对象,pObj指向对象的地址</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isKindOf(AcDbLine::desc()); //这句语法对吗?要这么写吗?</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//后面该怎么写???&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acutPrintf("\nPicking failed!");<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;}</p><p>写到isKindOf函数,后面就写不下去了。<br/>因为编译时编译器提示错误C2065: "isKindOf()" : 未声明的标识符。<br/>另外,我在objectARX2004的arxdoc.chm中搜索AcDbLine::desc(),没有搜到相关内容。</p><p>各位达人能否给一小段实现pick单根线段获得端点坐标的ARX代码让我借鉴一下<br/></p><p>我现在就卡在这里了,请大家帮个忙,不胜感激</p>

BDYCAD 发表于 2007-3-15 11:48:00

<p>&nbsp;我的ARX还不太会,觉的这句&nbsp;<br/>isKindOf(AcDbLine::desc()); //这句语法对吗?要这么写吗?</p><p>应是<br/>&nbsp;isKindOf(AcDbLine::desc();); //这样写吧, </p><p>如果不对请不介意哦.我也是学习中....</p>

anston 发表于 2007-3-15 12:30:00

本帖最后由 作者 于 2007-3-15 12:40:40 编辑 <br /><br /> BDYCAD发表于2007-3-15 11:48:00static/image/common/back.gif&nbsp;我的ARX还不太会,觉的这句&nbsp;isKindOf(AcDbLine::desc()); //这句语法对吗?要这么写吗?应是&nbsp;isKindOf(AcDbLine::desc();); //这样写吧, 如果不对请不介意哦.我也是学习中....

<p>谢谢2楼的回复。不过</p><p>isKindOf(AcDbLine::desc(););&nbsp; //这句的写法显然是错的</p><p></p><p>我现在改成了这样:</p><p>pObj-&gt;isKindOf(AcDbLine::desc());&nbsp; //判断pObj指向的对象是直线??</p><p>编译就通过了。但不知道这样写有什么意义,而且后面的代码仍然不会。</p><p>等待指点中...</p>

老牛 发表于 2007-3-16 13:31:00

<p>if(pObj-&gt;isKindOf(AcDbLine::desc()) == true)</p><p>{</p><p>AcDbLine *pLine = AcDbLine::cast(pObj);</p><p>AcGePoint3d ptStart = pLine-&gt;startPoint();</p><p>AcGePoint3d ptEnd = pLine-&gt;endPoint();</p><p>}</p>

anston 发表于 2007-3-16 15:43:00

老牛发表于2007-3-16 13:31:00static/image/common/back.gifif(pObj-&gt;isKindOf(AcDbLine::desc()) == true){AcDbLine *pLine = AcDbLine::cast(pObj);AcGePoint3d ptStart = pLine-&gt;startPoint();AcGePoint3d ptEnd = pLine-&gt;endPoint();}

<p>牛大哥太厉害了,我要的就是这三句!</p><p>尤其是括号里的第一句,没有你的指点我怎么都不会写。</p><p>非常谢谢你的帮助:)</p>
页: [1]
查看完整版本: [求助]如何通过点击直线获得两端点的坐标