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

使用VBA添加支持路径

是否可以使用代码添加支持路径?使用VBA或Lisp?

杨佳 发表于 2006-12-11 17:34:08

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

雅莉 发表于 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)
)
<编辑(&gt);添加代码标签;Mav

陆风哥哥 发表于 2006-12-12 09:15:40

上面,我忘了提一件非常重要的事情:如果你用Lisp,don 35;039;t使用\字符分隔文件夹。改为使用\\

心灵自雨 发表于 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

最高粽院 发表于 2006-12-12 17:53:00

回顾我在上面的帖子,我在其中展示了一段关于添加支持路径的代码,我得到了可能会被误解的答案;我个人在lisp文件中添加了,我没有'我不是想高估自己。我只是想说,我只是想增加一些台词,让我的想法变得普通,因为这可能也会引起其他人的兴趣;我已经很多年没有说一口流利的英语了,所以如果有时我不't正确解释myshelf。
页: [1]
查看完整版本: 使用VBA添加支持路径