potencjalek 发表于 2022-7-5 23:49:20

pline测量

你好
我尝试创建简单的lisp例程,该例程允许从具有不同凸起的对象中获取长度,
所以我需要在图纸上画普林线,取它的长度,然后删除它
我编写了如下代码
 
(defun pline_measure ( / en_pline)
(command ".pline")
(setq en_pline (entlast))
(vlax-curve-getDistAtParam en (vlax-curve-getEndParam en_pline ))
(setq lz (vlax-curve-getDistAtParam en (vlax-curve-getEndParam en_pline )))
(entdel en_pline)
)
 
但它表明该命令是在该函数结束时执行的
为什么?
我应该做什么来强制lisp等待其余的代码,直到我完成绘制pline?

Snownut 发表于 2022-7-6 00:08:45

尝试在“Pline”之后添加“Pause”。

Tharwat 发表于 2022-7-6 00:13:12


 

(defun c:test (/ en_pline)
(command "._pline")
(while (> (getvar 'CMDACTIVE) 0) (command pause))
(if (setq en_pline (entlast))
   (progn (print (strcat "Length of Pline : < "
                         (rtos (vlax-curve-getDistAtParam en_pline (vlax-curve-getEndParam en_pline)) 2)
                         " > ."
               )
          )
          (entdel en_pline)
   )
)
(princ)
)

potencjalek 发表于 2022-7-6 00:21:50

谢谢
它工作得很好
为大家庆祝圣诞节

Tharwat 发表于 2022-7-6 00:33:02

 
不客气。
 
很乐意帮忙。

Lee Mac 发表于 2022-7-6 00:42:36

我建议在以下内容中加入更多的错误捕捉:
(defun c:pll ( / ent )
   (setq ent (entlast))
   (command "_.pline")
   (if
       (and
         (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\"))
         (not (eq ent (setq ent (entlast))))
       )
       (progn
         (princ (strcat "\nLength: " (rtos (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)))))
         (entdel ent)
       )
   )
   (princ)
)
(vl-load-com) (princ)
如果用户在PLINE命令处于活动状态时按ESC键(这将导致当前代码出错),或在指定两个顶点之前单击鼠标右键/按ENTER键(在这种情况下,当前程序将出错或删除上次创建的实体),则上述情况允许。
 

BIGAL 发表于 2022-7-6 00:54:38

可以肯定的是,我对长度使用的一种更简单的方法是(vla get length ent)它的另一个参数,如图层线型co ords等。
页: [1]
查看完整版本: pline测量