自动加载lisp
嗨,伙计们我为office开发了一个简单的电子表格,列出了我多年来收集的lisp例程,我认为这些例程非常有用。在电子表格中,有文件名、类别、描述栏,以及一些其他信息,用于链接到如何使用lisp的在线说明。目前,我只有*。lsp文件位于网络上的一个文件夹中,因此任何人都可以加载它。我只是想知道是否有可能在这些按钮旁边放一个按钮,或者一个链接,可以自动将lisp例程安装/加载到AutoCAD上以供永久使用?或者这会很复杂?我没有任何编程经验。 在AutoCad中,您可以使用工具=>加载应用程序=>启动套件内容并将其添加到其中。然后,每次AutoCad启动时,这些LISP都会添加到laod中。
因此,如果只有少数用户,您可以这样做(它甚至可以指向网络上的lisp文件,因此如果您更新它,它将为所有用户更新等等)。 请点击此处查看其他选项。
使用Excel构建acaddoc。lsp文件,不要忘记将其保存为简单的ASCII文件。在所有工作站上使用相同的字母映射所述网络驱动器将非常有用。
是的,我知道如何加载lisps,我只是想知道是否有一种自动化的方法。所以,只要有人按下一个按钮,它就会为你做一切。我觉得这是一个很酷的小功能。
此外,我还尝试在“acaddoc.lsp”文件中加载多个Lisp。它启动第一个lisp,但不启动第二个lisp。你必须在他们之间放一个分隔物吗? 如果你喜欢Lisp程序的套路,但像我一样,Lisp程序的挑战,我建议你去李Mac的网站,看看很多很棒的东西。
我最喜欢的一个是图层控制器,试试,你会喜欢的。谢谢李!
这只是李慷慨提供的众多方案之一。 是的,我用的很多Lisp程序是李·麦克斯。层控制器很棒!!我将把它推广到办公室的电脑上。特别适合工程师,因为他们从不分层!!!!! 你能把文件的第一行贴出来试着调试一下吗? 我在我的“acaddoc.lsp”文件中添加了2个lisp,第一个lisp“grd”在打开autoCAD会话时可以正常工作,但图层控制器不工作,文件显示(第一部分是我的公司编码):
(if
(and
(not (menugroup "mmacad"))
(findfile "mmacad.cuix")
);and
(command "menuload" "mmacad.cuix")
);if
(and
(menugroup "mmacad")
(menucmd "p50=+MMACAD.POP1")
);and
(setvar "SAVETIME" 10)
(setvar "layernotify" 0)
(setvar "layereval" 0)
(defun c:grd()
(setvar "cmdecho" 0)
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
(setq p1 (getpoint "\nLower left corner point: ")
p2 (getcorner p1 "\nOpposite corner: ")
xd (abs (- (car p2)(car p1)))
yd (abs (- (cadr p2)(cadr p1)))
st (getdist "\nStep : ")
nx (fix (/ xd st))
ny (fix ( / yd st))
)
(if (or (>= st (/ xd 2))(>= st (/ yd 2)))
(progn
(alert "Wrong parameters defined")(exit)(princ)))
(command "rectang" p1 p2)
(setq r1 (list (car p1)(+ (cadr p1) st)(caddr p1))
r2 (list (car p2)(cadr r1)(caddr p2)))
(command "pline" r1 r2 "")
(command "array" "L" "" "R" ny 1 st "")
(setq c1 (list (+ (car p1)st)(cadr p1)(caddr p1))
c2(list (car c1)(cadr p2)(caddr p2)))
(command "pline" c1 c2 "")
(command "array" "L" "" "R" 1 nx st "")
(setvar "cmdecho" 1)
(setvar "osmode" osm)
)This one should create simmetric grid:
Code:
(defun C:GCL (/)
;;-------------------=={ Layer Director }==-------------------;;
;; ;;
;;Uses a Command Reactor to automatically set the active ;;
;;layer upon the user invoking a command. ;;
;; ;;
;;Layer settings are stored in the list at the top of the ;;
;;program. The first entry in the list is the command on ;;
;;which the reactor will trigger, it may use wildcards. ;;
;;The second entry is the name of the layer to be set when;;
;;the command is called, this layer will be created if ;;
;;not present in the active drawing. ;;
;; ;;
;;The Director is enabled upon loading this program. ;;
;;It may be manually switched ON and OFF by typing ;;
;;'LDON' and 'LDOFF' respectively at the command line. ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;;Version 1.1 - 24-04-2012 ;;
;;------------------------------------------------------------;;
;;------------------------------------------------------------;;
;;Layer Data ;;
;;========================================================;;
;; ;;
;;Populate this list with commands for which the current ;;
;;layer should be changed. ;;
;; ;;
;;The first item is the name of a command that will cue a ;;
;;layer change. The command name should be the full command ;;
;;name, not an alias. This command name is not ;;
;;case-sensitive and may use wildcards. ;;
;; ;;
;;e.g. "TEXT,TEXT" will cue a layer change for the ;;
;;Text, DText and MText commands. ;;
;; ;;
;;e.g. "*LEADER" will cue a layer change for the Leader, ;;
;;QLeader and MLeader commands. ;;
;; ;;
;;The second item is the name of the Layer to be set to ;;
;;current when the command is called. This layer will be ;;
;;created if not present in the active drawing. ;;
;;------------------------------------------------------------;;
(setq *LayerDirector-LayerData*
'(
;; COMMAND LAYER NAME ;;
("TEXT,TEXT" "MM-Text" )
("DIM*" "MM-Dims")
("*VPORT*" "MM-Vport" )
("*LEADER" "MM-Text")
)
)
;;------------------------------------------------------------;;
;;Print Command Debug Mode[ t / nil ] ;;
;;========================================================;;
;; ;;
;;If set to T the program will print the command name when;;
;;a command is called. This is useful when determining ;;
;;the correct command name to use in the Layer Data list. ;;
;;------------------------------------------------------------;;
(setq *PrintCommand* nil)
;;------------------------------------------------------------;;
;;Commands:[ LDON / LDOFF ] ;;
;;========================================================;;
;; ;;
;;Use these to manually turn the Layer Director on & off. ;;
;;------------------------------------------------------------;;
(defun c:LDONnil (LM:LayerDirectort ))
(defun c:LDOFF nil (LM:LayerDirector nil))
;;------------------------------------------------------------;;
(defun LM:LayerDirector ( on / reactor )
(setq reactor
(car
(vl-member-if
(function
(lambda ( reactor )
(eq "LayerDirector" (vlr-data reactor))
)
)
(cdar (vlr-reactors :vlr-command-reactor))
)
)
)
(if on
(if reactor
(if (vlr-added-p reactor)
(princ "\nLayer Director already running.")
(progn
(vlr-add reactor)
(princ "\nLayer Director Enabled.")
)
)
(progn
(vlr-command-reactor "LayerDirector"
'(
(:vlr-commandwillstart . LM:LayerDirector-Set)
(:vlr-commandended . LM:LayerDirector-Reset)
(:vlr-commandcancelled . LM:LayerDirector-Reset)
(:vlr-commandfailed . LM:LayerDirector-Reset)
)
)
(princ "\nLayer Director Enabled.")
)
)
(if reactor
(progn
(vlr-remove reactor)
(princ "\nLayer Director Disabled.")
)
(princ "\nLayer Director not running.")
)
)
(princ)
)
(defun LM:LayerDirector-Set ( reactor params / layer tmp )
(if
(and
(setq params (strcase (car params)))
(setq layer
(cadar
(vl-member-if
(function
(lambda ( item )
(wcmatch params (strcase (car item)))
)
)
*LayerDirector-LayerData*
)
)
)
(setq tmp (LM:LayerDirector-CreateLayer layer))
(zerop (logand 1 (cdr (assoc 70 tmp))))
)
(progn
(setq *LayerDirector-OldLayer* (getvar 'clayer))
(setvar 'clayer layer)
)
)
(if *PrintCommand* (print params))
(princ)
)
(defun LM:LayerDirector-Reset ( reactor params / tmp )
(if
(and
(not (wcmatch (strcase (car params)) "U,UNDO"))
*LayerDirector-OldLayer*
(setq tmp (tblsearch "LAYER" *LayerDirector-OldLayer*))
(zerop (logand 1 (cdr (assoc 70 tmp))))
)
(progn
(setvar 'clayer *LayerDirector-OldLayer*)
(setq *LayerDirector-OldLayer* nil)
)
)
(princ)
)
(defun LM:LayerDirector-CreateLayer ( name )
(cond
( (tblsearch "LAYER" name))
( (entmake
(list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 name)
'(70 . 0)
)
)
)
)
)
;;------------------------------------------------------------;;
(vl-load-com)
(LM:LayerDirector t);; Director will run when loaded.
(princ)
;;------------------------------------------------------------;;
;; End of File ;;
;;------------------------------------------------------------;; 可以肯定的是,这是你的阿卡多克的内容。lsp文件?我认为最好将所有例程定义保存在自己的文件中,并在acaddoc中调用它们。lsp。例子:
(load "C:\\MyAutoLISPTools\\Routine1st.LSP" (prompt "\nUnable to load Routine1st!"))
(load "C:\\MyAutoLISPTools\\Routine2nd.LSP" (prompt "\nUnable to load Routine2nd!"))
...
(princ)
关于发布的代码,存在不平衡的偏执;更准确地说,这个定义不是封闭的:
(defun C:GCL (/) 谢谢MSasu
好的,我已经更新了阿卡多克。lsp,但当我打开AutoCAD时,LISP没有加载,它显示:
(if
(and
(not (menugroup "mmacad"))
(findfile "mmacad.cuix")
);and
(command "menuload" "mmacad.cuix")
);if
(and
(menugroup "mmacad")
(menucmd "p50=+MMACAD.POP1")
);and
(setvar "SAVETIME" 10)
(setvar "layernotify" 0)
(setvar "layereval" 0)
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\attnumber.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\BlkImport.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\ChangeBlockInsertionV1-3.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\copyinc.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\dimcurve.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\fa.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\fixtxt.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\grd.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\insertall.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LabelV1-1.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LayerDirectorV1-1.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LayoutTools.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\LDOrderV1-2.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\Legend.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\List block.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\ll.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\MaskV1-0.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\normblocks.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\num.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\ple.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\plen.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pline-3d-2d.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pllen.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\polylen.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pst.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\pt2blk.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\PtManagerV2-4.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\reorderpoints.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\StripMtext v5-0c.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\super.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\SuperFlatten 1.2b.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\t2m.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\TL.lsp (prompt "\nUnable to load Routine1st!"))
(load "P:\\Glasgow\\BNI\\ACAD BLOCKS\\Lisp Routines\\TrailpitswithTable.LSP (prompt "\nUnable to load Routine1st!"))
(princ)
页:
[1]
2