从DCL cal使用entsel
***警告:如果代码按原样运行,则如果选中“拾取图元”或“拾取图层”按钮,它将锁定AutoCAD***我在转换以前的select\u项目时遇到问题。lsp使用DCL接口运行。
在使用initget/cond显示菜单之前,它运行良好。
lisp中的错误行是:
((= optn 1)
(done_dialog)
(setq ent (car (entsel))
filt (list (assoc 0 (entget ent)))
itm (cdr(assoc 0 (entget ent))))
(cond
(= itm "ATTDEF") (setq itm "ATTRIBUTE")
(= itm "INSERT") (setq itm "BLOCK")
(= itm "MLINE") (setq itm "MULTILINE")
(= itm "LWPOLYLINE") (setq itm "POLYLINE")
(= itm "XLINE") (setq itm "CONSTRUCTION LINE")
)
(setq txt (strcat itm " Entity(s)"))
)
以及:
((= optn 51)
(done_dialog)
(setq ent (car (entsel))
filt (list (assoc 8 (entget ent)))
itm (cdr(assoc 8 (entget ent)))
txt (strcat "Layer " itm " items"))
)
如果选择了其他选项,DCL和lisp工作正常。
它应该:
1)退出DCL对话
2) 执行ensel以获取实体
3) 为varios设置一些变量
4) 然后退出cond转到ssget
但是,当代码试图在后台执行entsel时,对话框被锁定。
***警告:如果代码按原样运行,则如果选中“拾取图元”或“拾取图层”按钮,它将锁定AutoCAD***
选择_项。lsp
选择_项。DCL 快速浏览一下,在action\u互动程序中执行done\u对话框部分,例如(action\u互动程序“56”“(done\u dialog 56”))并使用(setq optn(start\u dialog)),然后检查对话框返回值(optn)
gr.Rlx
(defun c:Select_Items ( / dcl_id *error* ent filt itm optn ss txt )
(defun *error* ( msg )
(princ "error: ")
(princ msg)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun doButton (optn)
(cond
((= optn 1)
(done_dialog)
(setq ent (car (entsel))
filt (list (assoc 0 (entget ent)))
itm (cdr(assoc 0 (entget ent))))
(cond
(= itm "ATTDEF") (setq itm "ATTRIBUTE")
(= itm "INSERT") (setq itm "BLOCK")
(= itm "MLINE") (setq itm "MULTILINE")
(= itm "LWPOLYLINE") (setq itm "POLYLINE")
(= itm "XLINE") (setq itm "CONSTRUCTION LINE")
)
(setq txt (strcat itm " Entity(s)"))
)
((= optn 2)
(setq filt '((0 . "ATTDEF"))
txt "ATTRIBUTE Entity(s)")
(done_dialog)
)
((= optn 3)
(setq filt '((0 . "INSERT"))
txt "BLOCK Entity(s)")
(done_dialog)
)
((= optn 4)
(setq filt '((0 . "LINE"))
txt "LINE Entity(s)")
(done_dialog)
)
((= optn 5)
(setq filt '((0 . "LWPOLYLINE"))
txt "POLYLINE Entity(s)")
(done_dialog)
)
((= optn 6)
(setq filt '((0 . "*TEXT"))
txt "TEXT and/or MTEXT Entity(s)")
(done_dialog)
)
((= optn 51)
(done_dialog)
(setq ent (car (entsel))
filt (list (assoc 8 (entget ent)))
itm (cdr(assoc 8 (entget ent)))
txt (strcat "Layer " itm " items"))
)
((= optn 52)
(setq filt '((8 . "DIMENSIONS"))
txt "items on layer DIMENSIONS")
(done_dialog)
)
((= optn 53)
(setq filt '((8 . "NO PRINT"))
txt "items on layer NO PRINT")
(done_dialog)
)
((= optn 54)
(setq filt '((8 . "PCAB"))
txt "items on layer PCAB")
(done_dialog)
)
((= optn 55)
(setq filt '((8 . "SCREEN"))
txt "items on layer SCREEN")
(done_dialog)
)
((= optn 56)
(setq filt '((8 . "TEXT"))
txt "items on layer TEXT")
(done_dialog)
)
);; end cond
);; end (defun doButton (optn)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(if(not(setq dcl_id (load_dialog (findfile "Select_Items.dcl")))) ;;;--- Load the dcl file from disk into memory
(progn ;; progn1
(alert "The DCL file could not be loaded.")
(exit)
);; end progn1
;;;--- Else, the file was loaded
(progn;; progn2
;;;--- Load the dialog definition inside the DCL file
(if (not (new_dialog "Select_Items" dcl_id))
(progn
(alert "The Select_Items definition could not be found in the DCL file!")
(exit)
)
;;;--- Else, the definition was loaded
(progn ;; progn3
;;;--- If an action event occurs, do this function
(action_tile "1" "(done_dialog 1)")
(action_tile "2" "(done_dialog 2)")
(action_tile "3" "(done_dialog 3)")
(action_tile "4" "(done_dialog 4)")
(action_tile "5" "(done_dialog 5)")
(action_tile "6" "(done_dialog 6)")
(action_tile "51" "(done_dialog 51)")
(action_tile "52" "(done_dialog 52)")
(action_tile "53" "(done_dialog 53)")
(action_tile "54" "(done_dialog 54)")
(action_tile "55" "(done_dialog 55)")
(action_tile "56" "(done_dialog 56)")
(action_tile "cancel" "(done_dialog 0)")
(setq optn (start_dialog));;;--- Display the dialog box
(unload_dialog dcl_id) ;;;--- Unload the dialog box
(if (> optn 0)(doButton optn))
);; end progn3
);; end (not (new_dialog "Select_Items" dcl_id))
);; end progn2
);; end (if(not(setq dcl_id (load_dialog "Select_Items.dcl")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(if filt
(progn;; then
(sssetfirst nil (setq ss (ssget "_:L" filt)))
(if ss
(princ (strcat "\n "(itoa (sslength ss)) " "txt" Selected"))
(princ "\n Nothing Found")
)
);end progn/then
(princ "\nSelect Items Lisp Cancelled");; else
);; end (if (= stop nil)
(princ)
)
没有做任何进一步的检查。。。但是你可以/必须从你的doButton函数中删除所有done\u对话框,因为这现在是由你的动作块处理的(贴在quick上)
gr.Rlx Soopurb,谢谢Rix。
请告诉我,除了
(action_tile "1" "(done_dialog 1)")线?
<p> </p><p> (action_tile "cancel" "(done_dialog 0)")</p><p> (setq optn (start_dialog));;;--- Display the dialog box</p><p> (unload_dialog dcl_id) ;;;--- Unload the dialog box</p><p> (if (> optn 0)(doButton optn))</p><p> );; end progn3</p><p> );; end (not (new_dialog "Select_Items" dcl_id))</p><p></p> 我从来没有得到过,非常感谢你,显然你在创建lisp-DCL组合方面很熟练
不客气,继续练习:-)
不,我只是其中的一个,实际上我有时有点马虎,但迟早你自己糟糕的编码会在你面前爆发,你会努力做得更好。
gr.Rlx :-) :-) :-) :-) :-) :-) :-)
页:
[1]