iliekater 发表于 2006-12-11 17:01:46

使用 VBA 添加支持路径

可以通过使用代码来添加支持路径吗?无论是VBA还是Lisp?
**** Hidden Message *****

rkmcswain 发表于 2006-12-11 17:34:08

当然
如果您只想添加一个,您可以获取其中的内容,附加到其中,然后替换整个字符串
这里是一个LISP示例:http://discussion.autodesk.com/thread.jspa?messageID=4982432

iliekater 发表于 2006-12-12 08:57:27

我发现了几年前第一次发现的东西!代码来自AfraLisp(现在位于http://www.afralisp.net/),它是从http://www.acadx.com/复制的。它是这样的:
(defun addSP (dir pos / tmp c lst)
(setq        tmp ""
        c   -1
)
(if
    (not
      (member (strcase dir)
              (setq lst (mapcar 'strcase (parse (getenv "ACAD") ";")))
      )
    )
   (progn
       (if (not pos)
       (setq tmp (strcat (getenv "ACAD") ";" dir))
       (mapcar '(lambda (x)
                  (setq tmp (if (= (setq c (1+ c)) pos)
                                (strcat tmp ";" dir ";" x)
                                (strcat tmp ";" x)
                              )
                  )
                  )
               lst
       )
       )
       (setenv "ACAD" tmp)
   )
)
(princ)
)
;
;
;
;
;
(defun parse (str delim / lst pos)
(setq pos (vl-string-search delim str))
(while pos
    (setq lst (cons (substr str 1 pos) lst)
          str (substr str (+ pos 2))
          pos (vl-string-search delim str)
    )
)
(if (> (strlen str) 0)
    (setq lst (cons str lst))
)
(reverse lst)
)
Arguments : A folder path and the position at which to insert it. (0 based.)
Here's an example to add a support folder :
(addSP "c:\\afralisp" 3)
I , personally , added in the lisp file the following in order to call it directly an set my support paths :
( defun c:LoadMySupportPaths ( )
( addSP "c:\\Windows" 0)
( addSP "d:\\Windows" 1)
)
添加了代码标签Mav

iliekater 发表于 2006-12-12 09:15:40

在上面,我忘了提一件非常重要的事情:
如果你使用Lisp,不要使用\字符来分隔文件夹。请改用\\

iliekater 发表于 2006-12-12 09:49:14

在VBA
中Public Sub ACADStartup()
    Dim supppath As String
    'This will prevent you entering the same entry more than once
    supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
    If Not (InStr(1, supppath, "U:\TITLEBLOCKS") > 1) Then
      ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\TITLEBLOCKS"
    End If
    supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
    If Not (InStr(1, supppath, "U:\SYMBOLS") > 1) Then
      ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\SYMBOLS"
    End If
    supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
    If Not (InStr(1, supppath, "U:\PROJECTLOGS") > 1) Then
      ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\PROJECTLOGS"
    End If
    Exit Sub
End Sub

iliekater 发表于 2006-12-12 17:53:00

回顾我上面的帖子,其中我展示了我发现的关于添加支持路径的代码,我得到了可能会被误解的填充。当我写“我个人在lisp文件中添加了......”时,我并不想高估我的架子。我只是想说我只是有添加一些行的想法,并使我的想法变得普通,因为它可能也会引起其他人的兴趣。我已经很多年没有说过很好的英语了,所以如果有时我没有正确地表达我的架子,请原谅我。
页: [1]
查看完整版本: 使用 VBA 添加支持路径