乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 94|回复: 5

使用 VBA 添加支持路径

[复制链接]

23

主题

72

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
164
发表于 2006-12-11 17:01:46 | 显示全部楼层 |阅读模式
可以通过使用代码来添加支持路径吗?无论是VBA还是Lisp?

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
362
发表于 2006-12-11 17:34:08 | 显示全部楼层
当然
如果您只想添加一个,您可以获取其中的内容,附加到其中,然后替换整个字符串
这里是一个LISP示例:http://discussion.autodesk.com/thread.jspa?messageID=4982432
回复

使用道具 举报

23

主题

72

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
164
发表于 2006-12-12 08:57:27 | 显示全部楼层
我发现了几年前第一次发现的东西!代码来自AfraLisp(现在位于http://www.afralisp.net/),它是从http://www.acadx.com/复制的。它是这样的:
  1. (defun addSP (dir pos / tmp c lst)
  2.   (setq        tmp ""
  3.         c   -1
  4.   )
  5.   (if
  6.     (not
  7.       (member (strcase dir)
  8.               (setq lst (mapcar 'strcase (parse (getenv "ACAD") ";")))
  9.       )
  10.     )
  11.      (progn
  12.        (if (not pos)
  13.          (setq tmp (strcat (getenv "ACAD") ";" dir))
  14.          (mapcar '(lambda (x)
  15.                     (setq tmp (if (= (setq c (1+ c)) pos)
  16.                                 (strcat tmp ";" dir ";" x)
  17.                                 (strcat tmp ";" x)
  18.                               )
  19.                     )
  20.                   )
  21.                  lst
  22.          )
  23.        )
  24.        (setenv "ACAD" tmp)
  25.      )
  26.   )
  27.   (princ)
  28. )
  29. ;
  30. ;
  31. ;
  32. ;
  33. ;
  34. (defun parse (str delim / lst pos)
  35.   (setq pos (vl-string-search delim str))
  36.   (while pos
  37.     (setq lst (cons (substr str 1 pos) lst)
  38.           str (substr str (+ pos 2))
  39.           pos (vl-string-search delim str)
  40.     )
  41.   )
  42.   (if (> (strlen str) 0)
  43.     (setq lst (cons str lst))
  44.   )
  45.   (reverse lst)
  46. )
  47.   Arguments : A folder path and the position at which to insert it. (0 based.)
  48.   Here's an example to add a support folder :
  49. (addSP "c:\\afralisp" 3)
  50. I , personally , added in the lisp file the following in order to call it directly an set my support paths :
  51. ( defun c:LoadMySupportPaths ( )
  52.   ( addSP "c:\\Windows" 0)
  53.   ( addSP "d:\\Windows" 1)
  54. )

添加了代码标签Mav
回复

使用道具 举报

23

主题

72

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
164
发表于 2006-12-12 09:15:40 | 显示全部楼层
在上面,我忘了提一件非常重要的事情:
如果你使用Lisp,不要使用\字符来分隔文件夹。请改用\\
回复

使用道具 举报

23

主题

72

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
164
发表于 2006-12-12 09:49:14 | 显示全部楼层
在VBA
  1. Public Sub ACADStartup()
  2.     Dim supppath As String
  3.     'This will prevent you entering the same entry more than once
  4.     supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
  5.     If Not (InStr(1, supppath, "U:\TITLEBLOCKS") > 1) Then
  6.         ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\TITLEBLOCKS"
  7.     End If
  8.     supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
  9.     If Not (InStr(1, supppath, "U:\SYMBOLS") > 1) Then
  10.         ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\SYMBOLS"
  11.     End If
  12.     supppath = UCase(ThisDrawing.Application.Preferences.Files.SupportPath)
  13.     If Not (InStr(1, supppath, "U:\PROJECTLOGS") > 1) Then
  14.         ThisDrawing.Application.Preferences.Files.SupportPath = supppath & ";U:\PROJECTLOGS"
  15.     End If
  16.     Exit Sub
  17. End Sub

回复

使用道具 举报

23

主题

72

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
164
发表于 2006-12-12 17:53:00 | 显示全部楼层
回顾我上面的帖子,其中我展示了我发现的关于添加支持路径的代码,我得到了可能会被误解的填充。当我写“我个人在lisp文件中添加了......”时,我并不想高估我的架子。我只是想说我只是有添加一些行的想法,并使我的想法变得普通,因为它可能也会引起其他人的兴趣。我已经很多年没有说过很好的英语了,所以如果有时我没有正确地表达我的架子,请原谅我。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-7 05:00 , Processed in 1.398202 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表