找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 699|回复: 0

[文件] (XD::FILE:ResolveRelativePath)相对路径处理

[复制链接]

已领礼包: 20个

财富等级: 恭喜发财

发表于 2017-12-11 10:53:19 | 显示全部楼层 |阅读模式
函数发布
函数名称: XD::FILE:ResolveRelativePath
调用格式: (XD::FILE:ResolveRelativePath filePath dwgPath)
参数说明: fileNamePath --- 文件路径
dwgPath --- DWG文件目录
返回值: 字符串
函数简介: 相对路径处理
函数来源: 转载
函数作者: marting
适用版本: 不限 
最后更新时间: 2017-12-11
备注: -
演示图片: -

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
  1. ;; Returns a filename based on the resolved path
  2. ;; Usage: (XD::FILE:ResolveRelativePath "..\\grid.dwg" (getvar "dwgprefix"))
  3. (defun XD::FILE:ResolveRelativePath (fileNamePath dwgPath / )
  4.   ; Check for relative paths and attempt to resolve the path to the xref
  5.   (cond
  6.     ; Relative path, should resolve multiple levels of relative folders; DWG file must be saved
  7.     ((and (= (substr fileNamePath 1 2) "..")(/= (getvar "dwgprefix") ""))
  8.       (while (= (substr fileNamePath 1 2) "..")
  9.         (setq fileNamePath (substr fileNamePath 4)
  10.               dwgPath (substr dwgPath 1 (vl-string-position (ascii "\\") dwgPath 0 T))
  11.         )
  12.       )
  13.       (setq fileNamePath (strcat dwgPath "\\" fileNamePath))
  14.     )
  15.     ; Absolute paths, resolves only the top level folder; DWG file must be saved
  16.     ((and (= (substr fileNamePath 1 1) ".")(/= (getvar "dwgprefix") ""))
  17.       (setq fileNamePath (substr fileNamePath 3)
  18.             fileNamePath (strcat dwgPath "\\" fileNamePath)
  19.       )
  20.     )
  21.   )  
  22.   ; Check to see if the fileNamePath is valid, if not then attempt to locate the file in the working support path
  23.   (if (not (findfile fileNamePath))
  24.     (setq fileNamePath (findfile (strcat (vl-filename-base fileNamePath) (vl-filename-extension fileNamePath))))
  25.     (if (= (vl-filename-directory fileNamePath) "")
  26.       (setq fileNamePath (findfile fileNamePath))
  27.     )
  28.   )
  29.   ; Returns the resolved path with filename, if the path couldn't be resolved
  30.   ; then the original fileNamePath is returned
  31.   fileNamePath
  32. )


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-25 09:10 , Processed in 0.313061 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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