乐筑天下

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

使用VBA添加支持路径

[复制链接]

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2006-12-11 17:01:46 | 显示全部楼层 |阅读模式
是否可以使用代码添加支持路径?使用VBA或Lisp?
回复

使用道具 举报

0

主题

8

帖子

4

银币

初来乍到

Rank: 1

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

使用道具 举报

0

主题

7

帖子

6

银币

初来乍到

Rank: 1

铜币
9
发表于 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. )

<编辑(&gt);添加代码标签;Mav
回复

使用道具 举报

0

主题

10

帖子

4

银币

初来乍到

Rank: 1

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

使用道具 举报

0

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
9
发表于 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
回复

使用道具 举报

0

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
10
发表于 2006-12-12 17:53:00 | 显示全部楼层
回顾我在上面的帖子,我在其中展示了一段关于添加支持路径的代码,我得到了可能会被误解的答案;我个人在lisp文件中添加了,我没有'我不是想高估自己。我只是想说,我只是想增加一些台词,让我的想法变得普通,因为这可能也会引起其他人的兴趣;我已经很多年没有说一口流利的英语了,所以如果有时我不't正确解释myshelf。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

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

© 2020-2025 乐筑天下

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