Wojciech 发表于 2022-7-5 23:25:38

多段线部分的长度

你好
 
是否有lisp脚本来测量多段线的长度部分?我想选择(仅一条)多段线,现在选择多段线上的点A,以及多段线上的下一个点B。然后我得到这条多段线的一部分长度(不切割这条多段线…)。
 
问候语

pBe 发表于 2022-7-5 23:39:35

(Defun c:demo (/ p1 p2 obj)
(and
   (setq p1 (getpoint "\nPick Point A"))
   (setq
   p2 (getpoint p1 "\nPick point B")
   )
   (setq obj (car (nentselp p1)))
   (print (abs        (- (vlax-curve-getdistatpoint
             obj
             (vlax-curve-getclosestpointto obj p1)
           )
           (vlax-curve-getdistatpoint
             obj
             (vlax-curve-getclosestpointto obj p2)
           )
        )
   )
   )
)(princ)
)

Tharwat 发表于 2022-7-5 23:42:57

我看到pBe打败了我。
 
这是我的密码。
 

(defun c:Test (/ _LW-p 1p o 2p a b d e)
;;    Tharwat 11. Mar. 2014         ;;
;;    Measure distance on Polyline by    ;;
;;    picking two points      ;;
(defun _LW-p (p / e o n)
   (if (setq e (ssget p '((0 . "LWPOLYLINE"))))
   (setq o (cdr (assoc -1 (entget (setq n (ssname e 0))))))
   )
   (list o n)
)
(if (and (setq 1p (getpoint "\n Specify point on Polyline :"))
          (car (setq o (_LW-p 1p)))
          (setq 2p (getpoint "\n Specify point on the same Polyline :"))
          (if (eq (car o) (car (_LW-p 2p)))
            t
            (alert "You should pick two points on the same polyline ")
          )
   )
   (progn (cond ((equal (setq a (vlax-curve-getdistatpoint (setq e (cadr o)) 1p))
                        (setq b (vlax-curve-getdistatpoint e 2p))
                        1e-8
               )
               (setq d 0.)
                )
                (t
               (if (> a b)
                   (setq d (- a b))
                   (setq d (- b a))
               )
                )
          )
          (alert (strcat "Distance is : < " (rtos d 2) " > ."))
   )
)
(princ)
)
(vl-load-com)

prodromosm 发表于 2022-7-5 23:54:14

嗨,塔尔瓦特。我觉得少了点什么。如果在多段线上有2个特定点,并使用osnap节点选择lisp停止的第一个点。
我认为那样会更有用
 
1) 选择多段线
2) 指定多段线上的第一个点
3) 指定多段线上的第二个点
 
4) (警报(strcat“距离为:.”)

Tharwat 发表于 2022-7-6 00:01:11

 
我知道,它停止了,因为你在点对象上选择了一个点,而不是在多段线上。

alanjt 发表于 2022-7-6 00:11:59

这是我不久前做的一个。。。
 
http://cadtips.cadalyst.com/distance/determine-distance-between-points-entity

liuhaixin88 发表于 2022-7-6 00:20:06

 
非常好!谢谢分享

Wojciech 发表于 2022-7-6 00:32:23

非常感谢。
页: [1]
查看完整版本: 多段线部分的长度