天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 138|回复: 0

构建一个 ACADDOC.lsp,以便在启动时加载驻留在特定环境中的程序 目录

[复制链接]
  • TA的每日心情
    开心
    9 小时前
  • 签到天数: 79 天

    [LV.6]常住居民II

    616

    主题

    158

    回帖

    3173

    积分

    高级会员

    积分
    3173
    QQ
    发表于 2024-2-21 15:52:56 | 显示全部楼层 |阅读模式
    1. ;;-----------------=={ ACADDOC.lsp Creator }==----------------;;
    2. ;;                                                            ;;
    3. ;;  Creates, or appends to, an ACADDOC.lsp file containing    ;;
    4. ;;  a series of load statements for all program files         ;;
    5. ;;  (lsp/vlx/fas) found in a selected directory.              ;;
    6. ;;------------------------------------------------------------;;
    7. ;;  Author: Lee Mac, Copyright ?2011 - www.lee-mac.com       ;;
    8. ;;------------------------------------------------------------;;
    9. ;;  Version 1.1    -    25-05-2011                            ;;
    10. ;;------------------------------------------------------------;;

    11. (defun c:acaddoc ( / f p d l )
    12.   (if
    13.     (and
    14.       (or (setq f (findfile "ACADDOC.lsp"))
    15.         (and (setq p (LM:GetSavePath)) (setq f (strcat p "\\ACADDOC.lsp")))
    16.       )
    17.       (setq d (LM:DirectoryDialog "\nSelect Program File Directory" nil 512))
    18.       (setq l
    19.         (apply 'append
    20.           (mapcar '(lambda ( typ ) (LM:GetAllFiles d nil typ)) '("*.vlx" "*.fas" "*.lsp"))
    21.         )
    22.       )
    23.       (setq f (open f "a"))
    24.     )
    25.     (progn
    26.       (foreach x l
    27.         (write-line
    28.           (strcat "(load "
    29.             (vl-prin1-to-string x) " "--> Failed to Load: " (vl-filename-base x) "")"
    30.           )
    31.           f
    32.         )
    33.       )
    34.       (close f)
    35.       (princ (strcat "\n<<-- Written " (itoa (length l)) " Files to Load in ACADDOC.lsp -->>"))
    36.     )
    37.     (princ "\n*Cancel*")
    38.   )
    39.   (princ)
    40. )

    41. ;;-------------------=={ Directory Dialog }==-----------------;;
    42. ;;                                                            ;;
    43. ;;  Displays a dialog prompting the user to select a folder   ;;
    44. ;;------------------------------------------------------------;;
    45. ;;  Author: Lee Mac, Copyright ?2011 - www.lee-mac.com       ;;
    46. ;;------------------------------------------------------------;;
    47. ;;  Arguments:                                                ;;
    48. ;;  msg  - message to display at top of dialog                ;;
    49. ;;  dir  - root directory (or nil)                            ;;
    50. ;;  flag - bit coded flag specifying dialog display settings  ;;
    51. ;;------------------------------------------------------------;;
    52. ;;  Returns:  Selected folder filepath, else nil              ;;
    53. ;;------------------------------------------------------------;;

    54. (defun LM:DirectoryDialog ( msg dir flag / Shell Fold Self Path )
    55.   (vl-catch-all-apply
    56.     (function
    57.       (lambda ( / ac HWND )
    58.         (if
    59.           (setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object)) "Shell.Application")
    60.                 HWND  (vl-catch-all-apply 'vla-get-HWND (list ac))
    61.                 Fold  (vlax-invoke-method Shell 'BrowseForFolder (if (vl-catch-all-error-p HWND) 0 HWND) msg flag dir)
    62.           )
    63.           (setq Self (vlax-get-property Fold 'Self)
    64.                 Path (vlax-get-property Self 'Path)
    65.                 Path (vl-string-right-trim "\" (vl-string-translate "/" "\" Path))
    66.           )
    67.         )
    68.       )
    69.     )
    70.   )
    71.   (if Self  (vlax-release-object  Self))
    72.   (if Fold  (vlax-release-object  Fold))
    73.   (if Shell (vlax-release-object Shell))
    74.   Path
    75. )

    76. ;;--------------------=={ Get All Files }==-------------------;;
    77. ;;                                                            ;;
    78. ;;  Retrieves all files or those of a specified filetype that ;;
    79. ;;  reside in a directory (and, optionally, subdirectories)   ;;
    80. ;;------------------------------------------------------------;;
    81. ;;  Author: Lee Mac, Copyright ?2011 - www.lee-mac.com       ;;
    82. ;;------------------------------------------------------------;;
    83. ;;  Arguments:                                                ;;
    84. ;;  Dir      - Directory to search                            ;;
    85. ;;  Subs     - Boolean, if T, subdirectories are included     ;;
    86. ;;  Filetype - (optional) Filter for filetype (DOS pattern)   ;;
    87. ;;------------------------------------------------------------;;
    88. ;;  Returns:  List of filenames, else nil if none are found   ;;
    89. ;;------------------------------------------------------------;;

    90. (defun LM:GetAllFiles ( Dir Subs Filetype / _GetSubFolders )
    91.   
    92.   (defun _GetSubFolders ( folder )
    93.     (apply 'append
    94.       (mapcar
    95.         (function
    96.           (lambda ( f )
    97.             (cons (setq f (strcat folder "\" f)) (_GetSubFolders f))
    98.           )
    99.         )
    100.         (vl-remove "." (vl-remove ".." (vl-directory-files folder nil -1)))
    101.       )
    102.     )
    103.   )

    104.   (apply 'append
    105.     (mapcar
    106.       (function
    107.         (lambda ( Filepath )
    108.           (mapcar
    109.             (function
    110.               (lambda ( Filename ) (strcat Filepath "\" Filename))
    111.             )
    112.             (vl-directory-files Filepath Filetype 1)
    113.           )
    114.         )
    115.       )
    116.       (cons Dir (if subs (_GetSubFolders Dir)))
    117.     )
    118.   )
    119. )

    120. ;;--------------------=={ Get Save Path }==-------------------;;
    121. ;;                                                            ;;
    122. ;;  Returns a save path in an AutoCAD Support Directory       ;;
    123. ;;------------------------------------------------------------;;
    124. ;;  Author: Lee Mac, Copyright ?2010 - www.lee-mac.com       ;;
    125. ;;------------------------------------------------------------;;
    126. ;;  Arguments: -None-                                         ;;
    127. ;;------------------------------------------------------------;;
    128. ;;  Returns: Save path in AutoCAD Support Directory, else nil ;;
    129. ;;------------------------------------------------------------;;

    130. (defun LM:GetSavePath ( / path )
    131.   (if
    132.     (vl-file-directory-p
    133.       (setq path
    134.         (vl-string-right-trim "\"
    135.           (vl-string-translate "/" "\"
    136.             (substr (getenv "ACAD") 1 (vl-string-position 59 (getenv "ACAD")))
    137.           )
    138.         )
    139.       )
    140.     )
    141.     path
    142.   )
    143. )

    144. (princ) (vl-load-com) (princ)

    复制代码
    构建一个 ACADDOC.lsp,以便在启动时加载驻留在特定环境中的程序 目录
    深圳市诺科空间膜结构有限公司 专业膜结构设计施工20年,一级设计一级施工  www.nkmjg.cn 欢迎联系电话:138-2526-2292
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|中国膜结构网_中国空间膜结构协会

    GMT+8, 2024-6-1 19:53 , Processed in 0.060719 second(s), 23 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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