明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 536|回复: 1

[提问] 求 获得当前文档目录的上级目录

[复制链接]
发表于 2017-8-27 20:23 | 显示全部楼层 |阅读模式
有高手在么?
能不能帮我处理个问题呢
经常修改图纸,想按时间建立文件夹,自己改的有点问题,只能建立在打开文件的同级目录里面,
想修改成建立在当前文档的上级目录中,请大神们不吝赐教。
比如
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)")) ;[YY年MO月DD日][HH-MM-SS]
(vl-mkdir (strcat path "\\"date))
(princ (strcat "\n  文件夹的路径是:"path))
(princ)
)



"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2017-8-29 18:15 | 显示全部楼层


(setq DwgDir "D:\\tangent\\TwtT20V3\\sys18x64\\")

(split DwgDir "\\")
===>
("D:" "tangent" "TwtT20V3" "sys18x64" "")

=================

http://www.cadtutor.net/forum/sh ... -Based-on-Delimiter


  1. ;; Usage: (split (getenv "ACADPrefix") ";")
  2. (defun split (sExpression sDelimiter / len val sList)
  3.   ; Get the length of the first item from the expression based
  4.   ; on delimiter position
  5.   (setq len (vl-string-position (ascii sDelimiter) sExpression))

  6.   ; Loop until there are no more instances of the delimiter
  7.   ; in the expression
  8.   (while (numberp len)
  9.     ; Get the item from the expression
  10.     (setq val (substr sExpression 1 len))

  11.     ; Append the item to the list
  12.     (setq sList (cons val sList))

  13.     ; Get the remaining part of the expression
  14.     (setq sExpression (substr sExpression (+ 2 len)))

  15.     ; Get the length of the next item from the string based
  16.     ; on delimiter position
  17.     (setq len (vl-string-position (ascii sDelimiter) sExpression))
  18.   )

  19.   ; Add the last value to the list
  20.   (if (/= sExpression nil)
  21.     (setq sList (cons sExpression sList))
  22.   )

  23.   ; Reverses the elements in the list and return the list
  24.   (reverse sList)
  25. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-3-29 14:12 , Processed in 0.213834 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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