matichen 发表于 2002-8-19 13:00:00

关于PL线长度的问题[求助]

1.怎样将一条pl线的长度赋予一个变量?
2.一条pl线的其中一段的长度呢?
3.从pl线(不是直线)其中一点(点选)到指点长度的点。如何得到。

问题多多。望各位高手不吝指导。

lzfat 发表于 2002-8-19 13:34:00

参考!

可以参考这个论坛中的将所有PL点的坐标读出来的程序,那样你就会更有头绪的!

龙龙仔 发表于 2002-8-19 15:00:00

只供参考计算线加总长度

;;;-----------------------------------------------------
;;;计算线加总长度
;;;BY LUCAS(龙龙仔)
;;;2002/8/14AM 9:00
;;;初版
;;;2002/8/18PM 1:00
;;;修正POLYLINE & SPLINE没有CLOSED
;;;但首尾点相连,长度不能计算问题
;;;-----------------------------------------------------
(defun C:LENOF (/ CURVE TLEN SS N SUMLEN ENT_N ENT_SS)
(defun GETPLVTX (E / PL P10)
    (setq E (cdr (assoc -1 (entget E))))
    (while (setq E (entnext E))
      (if (setq P10 (cdr (assoc 10 (entget E))))
        (setq PL (cons P10 PL))
      )
    )
    (equal (nth 0 PL) (nth 0 (reverse PL)))
)
(vl-load-com)
(setq SUMLEN 0)
(setq
    SS (ssget
       '((0 . "CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC"))
       )
)
(setq N 0)
(repeat (sslength SS)
    (setq ENT_SS (entget (ssname SS N)))
    (setq ENT_N (cdr (assoc 0 ENT_SS)))
    (cond
      ((or (= "CIRCLE" ENT_N)
           (and        (= "LWPOLYLINE" ENT_N)
                (or (= 1 (cdr (assoc 70 ENT_SS)))
                  (equal (assoc 10 ENT_SS)
                           (assoc 10 (reverse ENT_SS))
                  )
                )
           )
           (and        (= "SPLINE" ENT_N)
                (or (= 1 (rem (cdr (assoc 70 ENT_SS)) 2))
                  (equal (assoc 10 ENT_SS)
                           (assoc 11 (reverse ENT_SS))
                  )
                )
           )
           (and        (= "POLYLINE" ENT_N)
                (or (= 1 (rem (cdr (assoc 70 ENT_SS)) 2))
                  (GETPLVTX (ssname SS N))
                )
           )
           (= "ELLIPSE" ENT_N)
       )
       (command "AREA" "O" (ssname SS N))
       (setq TLEN (getvar "PERIMETER"))
      )
      (t
       (setq CURVE (vlax-ename->vla-object (ssname SS N)))
       (setq TLEN (vlax-curve-getdistatpoint
                  CURVE
                  (vlax-curve-getendpoint CURVE)
                  )
       )
      )
    )
    (setq N (1+ N))
    (setq SUMLEN (+ SUMLEN TLEN))
)
(print (strcat "总长度: " (rtos SUMLEN 2 5)))
(princ)
)

陈伯雄 发表于 2002-8-19 16:15:00

做什么用?

ll_j 发表于 2002-8-19 17:28:00

一点参考。

1.用 Area o 查看后的系统变量 PERIMETER 值。
2.没有直接方法,可以编程:在两点分别截断,然后求中段。
3.从指定点截断,然后 measure,第一点就是所求(注意删除其他点,使用函数entlast、entnext等。

matichen 发表于 2002-8-19 18:15:00

1、3 很有启发,2好像不好搞。多谢!

matichen 发表于 2002-8-19 18:16:00

道路长度输出。

matichen 发表于 2002-8-19 18:17:00

好东东,研究一下再说。多谢!

matichen 发表于 2002-8-19 18:18:00

那pl中弧线段如何得到点?

ll_j 发表于 2002-8-19 18:30:00

供参考

这是早期写的测量R12多线的程序,后来没有更新,供参考:
(defun l::pl()
;(redraw (car p:se1) 3)
(setq p:e11 (entnext p:e01)
      p:e12 (entget p:e11)
      p:e13 (cdr (assoc 10 p:e12))
      p:e21 p:e01 p:e32 p:e12
)
(while (= (cdr (assoc 0 p:e32)) "VERTEX")       ;3DPL采用实体跟随
    (setq p:e23 p:e33
          p:e31 (entnext p:e21)
          p:e32 (entget p:e31)
          p:e33 (cdr (assoc 10 p:e32))
          p:e21 p:e31
    )
)
(setq p:pt1 (getpoint "\nStart point: ")
      p:pt2 (getpoint "\nEnd point: ")
      p:pt0 (osnap (cadr p:se1) "nea")
      p:num 3                        ;剪断后UNDO步数
)
(if (or (equal p:pt1 p:e13) (equal p:pt1 p:e23))    ;判断顶点
    (setq p:num (- num 1))
    (command "break" p:se1 "f" p:pt1 p:pt1))
(if (or (equal p:pt2 p:e13) (equal p:pt2 p:e23))
    (setq p:num (- num 1))
    (command "break" p:pt0 "f" p:pt2 p:pt2))
(command "area" "e" p:pt0)
(command "undo" p:num)                     ;UNDO_Break
)
(defun c:MEP(/ p:se1 p:pt1 p:pt2 p:pt0 p:e01 p:e02 p:e11 p:e12 p:e13
               p:e21 p:e23 p:e31 p:e32 p:e33 p:num)
(setq p:se1 (entsel "\nSelect pline: "))      ;注意选择点
(setq p:e01 (car p:se1)
      p:e02 (entget p:e01)
)
(if (/= (cdr (assoc 0 p:e02)) "POLYLINE")
    (progn
      (princ "\nThis entity is ")
      (princ (cdr (assoc 0 p:e02)))
      (princ ", I can't measure it.")
    )
    (l::pl)
)
(princ)
)
页: [1] 2
查看完整版本: 关于PL线长度的问题[求助]