求 获得当前文档目录的上级目录
有高手在么?能不能帮我处理个问题呢
经常修改图纸,想按时间建立文件夹,自己改的有点问题,只能建立在打开文件的同级目录里面,
想修改成建立在当前文档的上级目录中,请大神们不吝赐教。
比如
D:\tangent\TwtT20V3\sys18x64\下的dwg文件
运行程序后就能在
D:\tangent\TwtT20V3\ 下建立个时间文件夹
我的代码如下,欢迎修改
(defun c:xrq ( / path)
(setq path (getvar "dwgprefix"))
(setq date (menucmd "M=$(edtime,$(getvar,date),MO.DD)")) ;
(vl-mkdir (strcat path "\\"date))
(princ (strcat "\n文件夹的路径是:"path))
(princ)
)
(setq DwgDir "D:\\tangent\\TwtT20V3\\sys18x64\\")
(split DwgDir "\\")
===>
("D:" "tangent" "TwtT20V3" "sys18x64" "")
=================
http://www.cadtutor.net/forum/showthread.php?99724-Splitting-A-String-Into-A-List-of-Elements-Based-on-Delimiter
;; Usage: (split (getenv "ACADPrefix") ";")
(defun split (sExpression sDelimiter / len val sList)
; Get the length of the first item from the expression based
; on delimiter position
(setq len (vl-string-position (ascii sDelimiter) sExpression))
; Loop until there are no more instances of the delimiter
; in the expression
(while (numberp len)
; Get the item from the expression
(setq val (substr sExpression 1 len))
; Append the item to the list
(setq sList (cons val sList))
; Get the remaining part of the expression
(setq sExpression (substr sExpression (+ 2 len)))
; Get the length of the next item from the string based
; on delimiter position
(setq len (vl-string-position (ascii sDelimiter) sExpression))
)
; Add the last value to the list
(if (/= sExpression nil)
(setq sList (cons sExpression sList))
)
; Reverses the elements in the list and return the list
(reverse sList)
)
Andyhon 发表于 2017-8-29 18:15
(setq DwgDir "D:\\tangent\\TwtT20V3\\sys18x64\\")
(split DwgDir "\\")
谢谢!用上了
页:
[1]