BLOACH85 发表于 2022-7-6 15:25:19

这是代码,我所有的修复都没有成功。
 
(defun c:standardlayers (/ *error*)
   (defun *error* (msg)
   (and Osmode# (setvar "osmode" Osmode#))
   (command "_.undo" "_e")
   (if
   (not
   (member
   msg
   '("console break" "Function cancelled" "quit / exit abort")
   ) ;_ member
   ) ;_ not
            (princ (strcat "\nError: " msg))
   ) ;_ if
) ;_ defun
; Layers
(command "layer" "m" "Const"   "lt"   "continuous" "" "c" "1" "" "")
(command "layer" "m" "Steel"   "lt"   "continuous" "" "c" "2" "" "")
(command "layer" "m" "Dimension"   "lt"   "continuous" "" "c" "4" "" "")
(command "layer" "m" "Hidden""lt"   "Hidden" "" "c" "1" "" "")
(command "layer" "m" "Text"   "lt"   "continuous" "" "c" "7" "" "")
(command "layer" "m" "Welds"   "lt"   "continuous" "" "c" "6" "" "")
(command "layer" "m" "Ref"   "lt"   "continuous" "" "c" "8" "" "")
(command "-linetype" "load"   "hidden"""   "yes" "")
(princ)
);end of defun
(C:standardlayers)

 
当涉及到在例程中输入命令时,我只是处于停滞状态。

CmdrDuh 发表于 2022-7-6 15:29:32

这可行,但很难看。
(if (not (= (command "-layer" "s" "YourLayer" "") nil))
(command "-layer" "m" "YourLayer" "c" "2" "" "")
)
 
我不是一个Lisp程序的人,vba是我的东西,但原则是一样的

CmdrDuh 发表于 2022-7-6 15:31:24

下一步将是制作一个带有值的函数,以简化键入。大声思考

(defun CheckLayer(/ LayerName LayerColor LayerLinetype)
(if (not (= (command "-layer" "s" LayerName "") nil))
(command "-layer" "m" LayerName "c" LayerColor "" "lt" LayerLinetype "" "")
)
)
可以从主例程中调用
(选中层“Layer1Name”“Layer1Color”“L1LT”)

BLOACH85 发表于 2022-7-6 15:36:24

你是怎么做到的我得到的只是
命令:多个参数出错

The Buzzard 发表于 2022-7-6 15:38:04

试试看,
 
 
;;;/////////////////////////////////////////////////////////////////
(defun c:standardlayers ()                                          ;Define function
(SET_LAYER)                                                       ;Goto SET_LAYER Function
(princ)                                                         ;Exit quietly
)                                                                   ;End of define function
;;;/////////////////////////////////////////////////////////////////
(defun SET_LAYER ()                                                 ;Define function
(CREATE_LAYER "Const"   "1" "CONTINUOUS")                     ;Goto CREATE_Layer Function, Layer Name, Color, LineType
(CREATE_LAYER "Steel"   "2" "CONTINUOUS")                     ;Goto CREATE_Layer Function, Layer Name, Color, LineType
(CREATE_LAYER "Dimension" "4" "CONTINUOUS")                     ;Goto CREATE_Layer Function, Layer Name, Color, LineType
(CREATE_LAYER "Hidden"    "1" "HIDDEN")                           ;Goto CREATE_Layer Function, Layer Name, Color, LineType
(CREATE_LAYER "Text"      "7" "CONTINUOUS")                     ;Goto CREATE_Layer Function, Layer Name, Color, LineType
(CREATE_LAYER "Welds"   "6" "CONTINUOUS")                     ;Goto CREATE_Layer Function, Layer Name, Color, LineType
(CREATE_LAYER "Ref"       "8" "CONTINUOUS")                     ;Goto CREATE_Layer Function, Layer Name, Color, LineType
)                                                                   ;End define function
;;;/////////////////////////////////////////////////////////////////
(defun CREATE_LAYER (NLAY CLR LT / LAY FRZ)                         ;Define function, Declare variables and arguments
(setq LAY(tblsearch "layer" NLAY))                              ;Search drawing to find layer
(if                                                               ;If the following returns true
   (not LAY)                                                       ;Layer not in drawing
   (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "")         ;Layer command ~ make new layer with color and linetype
   (progn                                                          ;Then do the following
   (setq FRZ (cdr (assoc 70 LAY)))                               ;Variable FRZ is frozen layer
   (if (= FRZ 65)                                                ;Layer frozen from last edit
       (progn                                                      ;Then do the following
         (command "_.layer" "t" NLAY "")                           ;Thaw new layer if frozen
         (command "_.layer" "s" NLAY "")                           ;Set new layer
       )                                                         ;End progn (otherwise...)
       (command "_.layer" "s" NLAY "")                           ;Set new layer
   )                                                             ;End if
   )                                                               ;End progn (otherwise...)
)                                                               ;End if
)                                                                   ;End define function
;;;/////////////////////////////////////////////////////////////////

The Buzzard 发表于 2022-7-6 15:42:32

布洛赫,
 
抱歉,刚刚编辑了SET_LAYER功能,以进行颜色更正,以匹配您发布的功能。
 
秃鹰

Lee Mac 发表于 2022-7-6 15:46:06

这对你不管用吗?
 
http://www.cadtutor.net/forum/showpost.php?p=224949&postcount=5

The Buzzard 发表于 2022-7-6 15:47:57

这对我很有效。

CmdrDuh 发表于 2022-7-6 15:52:29

你试了哪一部分?第一个对我有用,第二个我想得很清楚

CmdrDuh 发表于 2022-7-6 15:55:40

经过更多测试后,它只在该层已经存在的情况下工作。我会使用李或Buzzard的方法,因为他们比我更了解LISP
页: 1 [2]
查看完整版本: 如何使lisp运行aut