选择ob的LISP语言
大家好,这是我第一次在这个论坛上,所以请原谅我,如果这已经张贴了。我正在尝试编写一个lisp例程,im noob as on lisps,我正在尝试执行以下操作:
;;=============================================
;;
;;描述:围绕选定的多重引线实体放置光晕效果。
;;
;;注意:这适用于AutoCAD形状文件和非True Type字体。
;;
;;=============================================
(定义c:halo()
(setq FLTR’(-4)。(0。“多重引线”)
(-4.“或>”)
)
)
(Princ“\n选择多重引线到光环(不能是true type字体)……”)
(princ“\n选择要处理的实体后按ENTER…”
(setq SS(ssget FLTR))
(命令“_.copy”ss”““0,0”“0,0”)
(命令“_.layer”“m”“halotext255”“c”“255”“”“lw”“2”“”“”)
(命令“_.chprop”ss“_la”“halotext255”“p”“c”“bylayer”)
;(命令“_.draworder”ss”“a”“p”)
)
现在,我想做的是,我使用quickselect,我想选择层“halotext255”上的所有多重引线,分解它们,然后选择分解的leaeder(层“halotext255”上的1 x实心线、1 x多段线和1 x直线)并删除它们,只在多重引线的文本下面留下多行文字。
非常感谢您的任何建议/帮助。 -在创建对象方面,First Entmake优于command
而不是
(command "_.layer" "m" "halotext255" "c" "255" "" "lw" "2" "" "")
使用
(entmake (list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 2Nme)
(cons 70 0)
(cons 62 Col)
(cons 6 Ltyp)
(cons 290 Plt)
(cons 370 LWgt)))
DXF代码使用AutoCAD 2011 DXF参考
-不要使用不需要的变量
而不是
(setq FLTR '((-4 . "<OR") (0 . "MULTILEADER") (-4 . "OR>")))
(setq SS (ssget FLTR))
使用
(setq SS (ssget '((-4 . "<OR") (0 . "MULTILEADER") (-4 . "OR>"))))
PS:参考代码发布指南 使用EXPLODE命令打断多重引线实体,并记住此操作的结果存储为以前的选择集;接下来,解析它以仅保留所需的实体。
只要您只查找一种类型,就不需要逻辑过滤器:
(setq FLTR '((-4 . "<OR")
(0 . "MULTILEADER")
(-4 . "OR>")
)
) 这个例子可以帮助您:
(if (setq ssetMLeaders (ssget "_:S" '((0 . "MULTILEADER"))))
(progn
(command "_EXPLODE" (ssname ssetMLeaders 0))
(setq ssetItems (ssget "_P"))
(repeat (setq index (sslength ssetItems))
(setq assocItem (entget (ssname ssetItems (setq index (1- index)))))
(if (/= (cdr (assoc 0 assocItem))
"MTEXT")
(entdel (cdr (assoc -1 assocItem)))
)
)
)
)
MSasu,
该代码可以工作,但有没有一种方法可以设置代码,这样我就不必手动选择它,我可以为该代码“选择上一个”吗,这就是我如何将其输入到我的代码中的方法:
;;Description: Place a HALO effect around selected multileader entities.
;;
;;Note: This works for AutoCAD shape files and not True Type Fonts.
;;
;;=============================================
(defun c:halo ()
(setq FLTR '( (-4 . "<OR")
(0 . "MULTILEADER")
(-4 . "OR>")
)
)
(Princ "\nSelect Multileader to HALO (CAN NOT be a true type font)...")
(princ "\nPress ENTER after selecting entities to process them...")
(setq SS (ssget FLTR))
(command "_.copy" ss "" "0,0" "0,0")
(command "_.layer" "m" "halotext255" "c" "255" "" "lw" "2" "" "")
(command "_.chprop" ss "" "_la" "halotext255" "p" "c" "bylayer" "")
(if (setq ssetMLeaders (ssget "_:S" '((0 . "MULTILEADER"))))
(progn
(command "_EXPLODE" (ssname ssetMLeaders 0))
(setq ssetItems (ssget "_P"))
(repeat (setq index (sslength ssetItems))
(setq assocItem (entget (ssname ssetItems (setq index (1- index)))))
(if (/= (cdr (assoc 0 assocItem))
"MTEXT")
(entdel (cdr (assoc -1 assocItem)))
)
)
)
)
;(command "_.draworder" ss "" "a" "p")
)
我认为我的代码和你的代码是两种不同的语言。当谈到lisps时,我仍然是noob,我的这段代码是类似的东西的修改版本。。。你能告诉我代码应该是什么样子吗?
有没有一个地方可以解释什么是“setq”以及所有括号的理由??我真的很想学习如何写Lisp程序。。。 如果我不理解您的井,您希望解析第一个选择集以保留标签:
(princ "\nPress ENTER after selecting entities to process them...")
(if (setq SS (ssget'((0 . "MULTILEADER"))))
(progn
(command "_.copy" ss "" "0,0" "0,0")
(command "_.layer" "m" "halotext255" "c" "255" "" "lw" "2" "" "")
(command "_.chprop" ss "" "_la" "halotext255" "p" "c" "bylayer" "")
(repeat (setq index1st (sslength ss))
(command "_EXPLODE" (setq tempItem (ssname ss (setq index1st (1- index1st)))))
(setq ssetItems (ssget "_P"))
(repeat (setq index2nd (sslength ssetItems))
(setq assocItem (entget (ssname ssetItems (setq index2nd (1- index2nd)))))
(if (/= (cdr (assoc 0 assocItem))
"MTEXT")
(entdel (cdr (assoc -1 assocItem)))
)
)
)
)
)
请再次检查我对选择过滤器的评论。
完全没有,只是普通的AutoLISP。 先生,你是一位大师!才华横溢,完美无瑕。
但还有一个问题,对不起,我如何将命令“HALO”合并到其中? 您只需要将例程中的代码替换为我修改的代码;还指示将变量本地化,并添加最终PRINC语句以安静退出(提示器上没有nil)。
(defun c:halo( / associtem index1st index2nd ss ssetitems tempitem )
(princ "\nPress ENTER after selecting entities to process them...")
(if (setq SS (ssget'((0 . "MULTILEADER"))))
(progn
(command "_.copy" ss "" "0,0" "0,0")
(command "_.layer" "_m" "halotext255" "_c" "255" "" "_lw" "2" "" "")
(command "_.chprop" ss "" "_la" "halotext255" "_p" "_c" "bylayer" "")
(repeat (setq index1st (sslength ss))
(command "_EXPLODE" (setq tempItem (ssname ss (setq index1st (1- index1st)))))
(setq ssetItems (ssget "_P"))
(repeat (setq index2nd (sslength ssetItems))
(setq assocItem (entget (ssname ssetItems (setq index2nd (1- index2nd)))))
(if (/= (cdr (assoc 0 assocItem))
"MTEXT")
(entdel (cdr (assoc -1 assocItem)))
)
)
)
)
)
(princ)
) 这很有效!非常感谢你。 不客气!
页:
[1]