马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- ;; Returns a filename based on the resolved path
- ;; Usage: (XD::FILE:ResolveRelativePath "..\\grid.dwg" (getvar "dwgprefix"))
- (defun XD::FILE:ResolveRelativePath (fileNamePath dwgPath / )
- ; Check for relative paths and attempt to resolve the path to the xref
- (cond
- ; Relative path, should resolve multiple levels of relative folders; DWG file must be saved
- ((and (= (substr fileNamePath 1 2) "..")(/= (getvar "dwgprefix") ""))
- (while (= (substr fileNamePath 1 2) "..")
- (setq fileNamePath (substr fileNamePath 4)
- dwgPath (substr dwgPath 1 (vl-string-position (ascii "\\") dwgPath 0 T))
- )
- )
- (setq fileNamePath (strcat dwgPath "\\" fileNamePath))
- )
- ; Absolute paths, resolves only the top level folder; DWG file must be saved
- ((and (= (substr fileNamePath 1 1) ".")(/= (getvar "dwgprefix") ""))
- (setq fileNamePath (substr fileNamePath 3)
- fileNamePath (strcat dwgPath "\\" fileNamePath)
- )
- )
- )
- ; Check to see if the fileNamePath is valid, if not then attempt to locate the file in the working support path
- (if (not (findfile fileNamePath))
- (setq fileNamePath (findfile (strcat (vl-filename-base fileNamePath) (vl-filename-extension fileNamePath))))
- (if (= (vl-filename-directory fileNamePath) "")
- (setq fileNamePath (findfile fileNamePath))
- )
- )
- ; Returns the resolved path with filename, if the path couldn't be resolved
- ; then the original fileNamePath is returned
- fileNamePath
- )
|