metal_pro 发表于 2022-7-6 11:48:45

如果线不是selec,则获取点

我正在创建一个例程,它将选择一条线,插入一个符号,然后断开,然后断开这条线(我所有的工作都完成了)。但是,我想添加一个功能,即在两次尝试后,没有选择任何线,将使用上次尝试的点。关于如何在不添加额外用户getpoint提示的情况下轻松获取这一点,有什么建议吗?
 
这是我用来选线的程序的一部分
 
(while (and (not linent) (< countr 2))
   (setq linent (entsel "\nPick Line for Block Insertion Point:"))
   (if    linent
   (progn
   (setq ed (entget (car linent)))
   (setq edd (dxf 0 ed))
   (if (and (/= edd "LINE") (/= edd "POLYLINE"))
   (setq linent nill)
   )
   )                  ;progn
   )                  ;if   

   (setq countr (1+ countr))
   (if    (not linent)
   (prompt "\nYou must select a LINE as Insertion Point !")
   )
)    ;while

Lee Mac 发表于 2022-7-6 12:15:22

点/对象检索的另一种方法:
 

(while
(progn
   (setq pt (getpoint "\nSelect Point for Block: "))

   (cond ((not pt) nil)

         ((not (setq ent (car (nentselp pt))))

            (princ "\n ** No Object Found at Point **"))

         ((not (eq "LINE" (cdr (assoc 0 (entget ent)))))

            (princ "\n** Object Must be a Line **")))))

LEsq 发表于 2022-7-6 12:44:04

对于那些喜欢短代码行的人,可以使用类似以下内容:
 
相同的

(eq (cdadr (entget ename)) "LINE")

 


(/= (cdadr (entget ename)) "LINE")

 
作为功能

(defun enameTarget (name) (eq (cdadr (entget ename)) name))

 
也许,等等,等等。。。

LEsq 发表于 2022-7-6 12:54:50

有机会和lisp玩一点。。。如果我理解的话,可能是这样的:
 
(defun C:测试(/tryouts data pt take)(setq tryouts 0)(而(
页: [1]
查看完整版本: 如果线不是selec,则获取点