明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 5759|回复: 24

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

  [复制链接]
发表于 2011-3-9 00:42:47 | 显示全部楼层 |阅读模式
本帖最后由 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知识,都是从电脑上面“摸”出来的,所以有很多更加方便快捷的知识对于我来说是未知的。。。也是我所学习的。。。谢谢


点评

我当宝收藏了!非常感谢  发表于 2012-3-13 08:15
发表于 2011-3-9 11:00:54 | 显示全部楼层
APPLOAD命令在启动组中添加是否方便些
发表于 2011-3-9 13:34:01 | 显示全部楼层
  1. ;;----------------------=={ AutoLoader }==--------------------;;
  2. ;;                                                            ;;
  3. ;;  Prompts for a directory selection and proceeds to write   ;;
  4. ;;  AutoLoad statements for all LISP files found in the       ;;
  5. ;;  selected directory to an output text file.                ;;
  6. ;;------------------------------------------------------------;;
  7. ;;  Author: Lee Mac, Copyright &copy; 2011        ;;
  8. ;;------------------------------------------------------------;;

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

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

  16.   (if
  17.     (and
  18.       (setq dir
  19.         (LM:DirectoryDialog
  20.           (strcat
  21.             "Select Directory of LISP files for which to generate AutoLoad expressions.\n"
  22.             "\nNote: Subdirectories of the selected directory will not be processed."
  23.           )
  24.           nil 832
  25.         )
  26.       )
  27.       (setq lst  (vl-directory-files (setq dir (vl-string-translate "\" "/" dir)) "*.lsp" 1))
  28.       (setq out  (getfiled "Create Output File" "" "txt" 1))
  29.       (setq file (open out "w"))
  30.     )
  31.     (progn
  32.       (mapcar
  33.         (function
  34.           (lambda ( lsp / syn )
  35.             (if (setq syn (LM:GetSyntax (strcat dir "/" lsp)))
  36.               (write-line
  37.                 (strcat "(autoload "
  38.                   (vl-prin1-to-string (strcat dir "/" lsp)) " '" (vl-prin1-to-string syn) ")"
  39.                 )
  40.                 file
  41.               )
  42.             )
  43.           )
  44.         )
  45.         lst
  46.       )
  47.       (setq file (close file)) (startapp "notepad" out)
  48.     )
  49.   )

  50.   (princ)
  51. )

  52. ;;--------------------=={ Get Syntax }==----------------------;;
  53. ;;                                                            ;;
  54. ;;  Returns a list of syntax for all defined commands in a    ;;
  55. ;;  supplied LISP file.                                       ;;
  56. ;;------------------------------------------------------------;;
  57. ;;  Author: Lee Mac, Copyright &copy; 2011 -        ;;
  58. ;;------------------------------------------------------------;;
  59. ;;  Arguments:                                                ;;
  60. ;;  file - filename of LISP file to read                      ;;
  61. ;;------------------------------------------------------------;;
  62. ;;  Returns:  List of defined commands in supplied LISP file  ;;
  63. ;;------------------------------------------------------------;;

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

  65.   (defun _GetSyntax ( p s / x )
  66.     (if (setq x (vl-string-search p s))
  67.       (cons
  68.         (substr (setq s (substr s (+ x 1 (strlen p)))) 1
  69.           (setq x
  70.             (car
  71.               (vl-sort
  72.                 (vl-remove 'nil
  73.                   (mapcar
  74.                     (function
  75.                       (lambda ( d ) (vl-string-position d s))
  76.                     )
  77.                    '(32 9 40 41)
  78.                   )
  79.                 )
  80.                 '<
  81.               )
  82.             )
  83.           )
  84.         )
  85.         (if x (_GetSyntax p (substr s (1+ x))))
  86.       )
  87.     )
  88.   )

  89.   (if (setq file (open file "r"))
  90.     (apply 'append
  91.       (progn
  92.         (while (setq line (read-line file))
  93.           (setq syntax (cons (_GetSyntax "(DEFUN C:" (strcase line)) syntax))
  94.         )
  95.         (setq file (close file)) (reverse syntax)
  96.       )
  97.     )
  98.   )
  99. )

  100. ;;-------------------=={ Directory Dialog }==-----------------;;
  101. ;;                                                            ;;
  102. ;;  Displays a dialog prompting the user to select a folder   ;;
  103. ;;------------------------------------------------------------;;
  104. ;;  Author: Lee Mac, Copyright &copy; 2011 -       ;;
  105. ;;------------------------------------------------------------;;
  106. ;;  Arguments:                                                ;;
  107. ;;  msg  - message to display at top of dialog                ;;
  108. ;;  dir  - root directory (or nil)                            ;;
  109. ;;  flag - bit coded flag specifying dialog display settings  ;;
  110. ;;------------------------------------------------------------;;
  111. ;;  Returns:  Selected folder filepath, else nil              ;;
  112. ;;------------------------------------------------------------;;

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

  116.   (setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object)) "Shell.Application")
  117.         HWND  (vl-catch-all-apply 'vla-get-HWND (list ac))
  118.         Fold  (vlax-invoke-method Shell 'BrowseForFolder (if (vl-catch-all-error-p HWND) 0 HWND)  msg flag dir))
  119.   (vlax-release-object Shell)
  120.   
  121.   (if Fold
  122.     (progn
  123.       (setq Self (vlax-get-property Fold 'Self) Path (vlax-get-property Self 'Path))
  124.       (vlax-release-object Self)
  125.       (vlax-release-object Fold)      
  126.       
  127.       (and (= "\" (substr Path (strlen Path)))
  128.            (setq Path (substr Path 1 (1- (strlen Path)))))
  129.     )
  130.   )
  131.   Path
  132. )

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

  137. ;;------------------------------------------------------------;;
  138. ;;                      End of File                           ;;
  139. ;;------------------------------------------------------------;;
发表于 2011-3-10 07:19:02 | 显示全部楼层
不错,可以在启动组和acad2006.lsp中添加启动的文件,注册表还没玩过,学习了。
发表于 2011-3-10 22:36:33 | 显示全部楼层
这个正是我想找的 谢谢了
发表于 2011-4-4 09:08:50 | 显示全部楼层
使用注册表来启动,还真没玩过,学习了。
发表于 2011-4-6 20:18:32 | 显示全部楼层
谢谢楼主,这是个好程序
发表于 2011-8-10 22:52:09 | 显示全部楼层
用此方法設定好後, 還可將注册表直匯出, 下次安裝CAD
再匯入即可, 簡單方便
发表于 2011-11-16 10:33:00 | 显示全部楼层
这个lsp有点像病毒哦,用过后是不是无法删除的啊,我用过一次自动加载的lsp,最后只能重装系统了
发表于 2011-11-16 17:02:47 | 显示全部楼层
謝謝,學習了....
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-26 06:50 , Processed in 0.203735 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表