another2121 发表于 2011-3-9 00:42:47

让CAD启动的时候自动加入LSP程序

本帖最后由 another2121 于 2011-11-20 22:49 编辑

      每次在用到LSP程序的时候,不是用LOAD、就是APPLOAD这两个命令,比较烦琐。。。。故在注册表中发现加入一个键值就能让CAD在每次启动的时候,自动加载LSP程序。。。。

   方法如下:
       1.打开注册表如下位置:(例:AUTOCAD 2006)
    HKEY_CURRENT_USER\software\autodesk\autocad\R16.2\acad-400:804\profies\<<未命名配置>>\dialogs\appload\startup
         《不同版本的CAD请选择相应的版本号(红色部分)》
          <使用CASS的朋友请选择   CASS XX   >   

       2.新建字符串值       1startup               内容:lsp文件所在路径及文件名。(如:C:\ABC\123.LSP)
          《如有多个文件,可以再建    2startup    3startup ................nstartup    内容都是相应lsp程序的路径》

       3.新建字符串值      numstartup          内容: 1
         《如有多个文件, 只须把上面的键值内容改成相应的数值就行了》

   4.关闭注册表,打开CAD...试试看。。。。。

    由于本人的CAD知识,都是从电脑上面“摸”出来的,所以有很多更加方便快捷的知识对于我来说是未知的。。。也是我所学习的。。。谢谢


szboy 发表于 2011-3-9 11:00:54

APPLOAD命令在启动组中添加是否方便些

sachindkini 发表于 2011-3-9 13:34:01

;;----------------------=={ AutoLoader }==--------------------;;
;;                                                            ;;
;;Prompts for a directory selection and proceeds to write   ;;
;;AutoLoad statements for all LISP files found in the       ;;
;;selected directory to an output text file.                ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright &copy; 2011      ;;
;;------------------------------------------------------------;;

(defun c:AutoLoader ( / *error* dir lst out file ) (vl-load-com)

(defun *error* ( msg )
    (if (and file (eq 'FILE (type file))) (close file))
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
      (princ (strcat "\n** Error: " msg " **")))
    (princ)
)

(if
    (and
      (setq dir
      (LM:DirectoryDialog
          (strcat
            "Select Directory of LISP files for which to generate AutoLoad expressions.\n"
            "\nNote: Subdirectories of the selected directory will not be processed."
          )
          nil 832
      )
      )
      (setq lst(vl-directory-files (setq dir (vl-string-translate "\\" "/" dir)) "*.lsp" 1))
      (setq out(getfiled "Create Output File" "" "txt" 1))
      (setq file (open out "w"))
    )
    (progn
      (mapcar
      (function
          (lambda ( lsp / syn )
            (if (setq syn (LM:GetSyntax (strcat dir "/" lsp)))
            (write-line
                (strcat "(autoload "
                  (vl-prin1-to-string (strcat dir "/" lsp)) " '" (vl-prin1-to-string syn) ")"
                )
                file
            )
            )
          )
      )
      lst
      )
      (setq file (close file)) (startapp "notepad" out)
    )
)

(princ)
)

;;--------------------=={ Get Syntax }==----------------------;;
;;                                                            ;;
;;Returns a list of syntax for all defined commands in a    ;;
;;supplied LISP file.                                       ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright &copy; 2011 -      ;;
;;------------------------------------------------------------;;
;;Arguments:                                                ;;
;;file - filename of LISP file to read                      ;;
;;------------------------------------------------------------;;
;;Returns:List of defined commands in supplied LISP file;;
;;------------------------------------------------------------;;

(defun LM:GetSyntax ( file / _GetSyntax line syntax )

(defun _GetSyntax ( p s / x )
    (if (setq x (vl-string-search p s))
      (cons
      (substr (setq s (substr s (+ x 1 (strlen p)))) 1
          (setq x
            (car
            (vl-sort
                (vl-remove 'nil
                  (mapcar
                  (function
                      (lambda ( d ) (vl-string-position d s))
                  )
                   '(32 9 40 41)
                  )
                )
                '<
            )
            )
          )
      )
      (if x (_GetSyntax p (substr s (1+ x))))
      )
    )
)

(if (setq file (open file "r"))
    (apply 'append
      (progn
      (while (setq line (read-line file))
          (setq syntax (cons (_GetSyntax "(DEFUN C:" (strcase line)) syntax))
      )
      (setq file (close file)) (reverse syntax)
      )
    )
)
)

;;-------------------=={ Directory Dialog }==-----------------;;
;;                                                            ;;
;;Displays a dialog prompting the user to select a folder   ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright &copy; 2011 -       ;;
;;------------------------------------------------------------;;
;;Arguments:                                                ;;
;;msg- message to display at top of dialog                ;;
;;dir- root directory (or nil)                            ;;
;;flag - bit coded flag specifying dialog display settings;;
;;------------------------------------------------------------;;
;;Returns:Selected folder filepath, else nil            ;;
;;------------------------------------------------------------;;

(defun LM:DirectoryDialog ( msg dir flag / Shell HWND Fold Self Path ac )
(vl-load-com)
;; &copy; Lee Mac 2010

(setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object)) "Shell.Application")
      HWND(vl-catch-all-apply 'vla-get-HWND (list ac))
      Fold(vlax-invoke-method Shell 'BrowseForFolder (if (vl-catch-all-error-p HWND) 0 HWND)msg flag dir))
(vlax-release-object Shell)

(if Fold
    (progn
      (setq Self (vlax-get-property Fold 'Self) Path (vlax-get-property Self 'Path))
      (vlax-release-object Self)
      (vlax-release-object Fold)      
      
      (and (= "\\" (substr Path (strlen Path)))
         (setq Path (substr Path 1 (1- (strlen Path)))))
    )
)
Path
)

(princ)
(princ "\n:: AutoLoader.lsp | &copy; Lee Mac 2011 ::")
(princ "\n:: Type \"AutoLoader\" to generate autoload expressions ::")
(princ)

;;------------------------------------------------------------;;
;;                      End of File                           ;;
;;------------------------------------------------------------;;

chengx2000 发表于 2011-3-10 07:19:02

不错,可以在启动组和acad2006.lsp中添加启动的文件,注册表还没玩过,学习了。

icefrog 发表于 2011-3-10 22:36:33

这个正是我想找的 谢谢了

gzbccy 发表于 2011-4-4 09:08:50

使用注册表来启动,还真没玩过,学习了。

yxl88168 发表于 2011-4-6 20:18:32

谢谢楼主,这是个好程序

mgame168 发表于 2011-8-10 22:52:09

用此方法設定好後, 還可將注册表直匯出, 下次安裝CAD
再匯入即可, 簡單方便

dcl1214 发表于 2011-11-16 10:33:00

这个lsp有点像病毒哦,用过后是不是无法删除的啊,我用过一次自动加载的lsp,最后只能重装系统了

urdiafa 发表于 2011-11-16 17:02:47

謝謝,學習了....
页: [1] 2 3
查看完整版本: 让CAD启动的时候自动加入LSP程序