vocabulary 发表于 2006-7-12 18:01:00

[求助]如何得到LWPolyLine的始点和终点座标?

<P>各位前辈:<BR>&nbsp;&nbsp;&nbsp; 一条LWPOLYLINE里用entget取得它的DXF组码后,很难DXF组码里得到这条线的起点和终点,请问各位有什么方法能得到这条LWPOLYLINE的起点和终点吗?先谢谢了!</P>

liu_kunlun 发表于 2006-7-12 18:43:00

<P>第一个10组码及最后一个10组码.</P>
<P>(setq pts (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget e)))</P>
<P>(setq pt-begin (cdr (car pts)) &nbsp;&nbsp;pt-end (cdr (last pts))&nbsp; )</P>

lht 发表于 2006-7-12 23:09:00

&nbsp;&nbsp;&nbsp;&nbsp; (setq s0 (car (entsel "\n请选择一条<STRONG>LWPolyLine</STRONG>线:"))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s0end (entget s0 )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;取出<STRONG>LWPolyLine</STRONG>线信息列表<BR>&nbsp;&nbsp;&nbsp;&nbsp; )<BR>&nbsp;&nbsp;&nbsp;&nbsp; ;;;——取出<STRONG>LWPolyLine</STRONG>线起点坐标P0———————————<BR>&nbsp;&nbsp;&nbsp;&nbsp; (setq n 0 p0 nil)<BR>&nbsp;&nbsp;&nbsp;&nbsp; (while (= p0 nil)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq plist (car (nth n s0end)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if (= plist 10) (setq p0 (cdr (nth n s0end))))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq n (+ n 1))<BR>&nbsp;&nbsp;&nbsp;&nbsp; )<BR>&nbsp;&nbsp;&nbsp;&nbsp; ;;;——取出<STRONG>LWPolyLine</STRONG>线终点坐标Pn———————————<BR>&nbsp;&nbsp;&nbsp;&nbsp; (setq n (- (length s0end) 1) pn nil)<BR>&nbsp;&nbsp;&nbsp;&nbsp; (while (= pn nil)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq plist (car (nth n s0end)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if (= plist 10) (setq pn (cdr (nth n s0end))))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq n (- n 1))<BR>&nbsp;&nbsp;&nbsp;&nbsp; )

BDYCAD 发表于 2006-7-13 09:30:00

本帖最后由 作者 于 2006-7-13 17:16:00 编辑

来个更快的(setq spname (car (entsel "\n选一条线:")))
(setq Mid-Point (vlax-curve-getPointAtDistspname (* 0.5(vlax-curve-getEndParam spname))));对象的中点
(setq spt (vlax-curve-getstartpoint spname));对象的起点
(setq ept (vlax-curve-getendpoint spname));对象的终点

ZZXXQQ 发表于 2006-7-13 16:51:00


(setq s0 (car (entsel "\n请选择一条LWPolyLine线:"))
      s0end (entget s0))   ;取出LWPolyLine线信息列表
(setq p0 (cdr (assoc 10 s0end)));;;—取出LWPolyLine线起点坐标P0—
(setq pn (cdr (assoc 10 (reverse s0end)))) ;;;—取出LWPolyLine线终点坐标Pn—

sjsapple 发表于 2006-8-12 15:50:00

<P>楼上真聪明!</P>
<P>&nbsp;</P>

无痕 发表于 2006-8-13 02:26:00

<P>推荐用4楼,通用性好</P>

jun353835273 发表于 2016-7-15 11:00:30

reverse 这个想法很好

z312144636 发表于 2024-5-21 14:16:57

reverse 这个想法很好
页: [1]
查看完整版本: [求助]如何得到LWPolyLine的始点和终点座标?