Return 其他格式的日期和时间 autocad
Return date and time in another format autocad
我的代码有点问题。我想显示来自 autocad 格式的时间和日期。例如,autocad 中的 tdcreate 命令显示 2458753.59648148,但此代码显示在输出文件 26 September 2019 14:18:55:999 中。我不知道哪里错了。我想出现 2458753.59648148 。
(progn
(foreach item
'(
("Current time:" "DATE" "DD MONTH YYYY HH:MM:SS:MSEC")
("Created:" "TDCREATE" "DD MONTH YYYY HH:MM:SS:MSEC")
("Last updated:" "TDUPDATE" "DD MONTH YYYY HH:MM:SS:MSEC")
("Total editing time:" "TDINDWG" "HH:MM:SS:MSEC")
("Elapsed timer:" "TDUSRTIMER" "HH:MM:SS:MSEC")
)
(write-line
(strcat
(PadRight (car item) " " 24)
(apply 'FormatDate (cdr item))
)
openfile
)
)
(close openfile)
(startapp "notepad" filename)
)
(princ (strcat "\nUnable to Write to " filename))
)
(princ)
)
(defun PadRight ( string char lengtth )
(if (< (strlen string) lengtth)
(PadRight (strcat string char) char lengtth)
string
)
)
(defun GetUniqueFilename ( seed / count file flist )
(if (findfile (setq file seed))
(progn
(setq count 1
flist (fnsplitl seed)
)
(while
(findfile
(setq file
(strcat
(car flist)
(cadr flist)
"(" (itoa (setq count (1+ count))) ")"
(caddr flist)
)
)
)
)
)
)
file
)
(defun FormatDate ( sysvar format )
(menucmd (strcat "m=$(edtime,$(getvar," sysvar ")," format ")"))
)
在 AutoCAD 中,TDCREATE
命令仅返回由 TDCREATE
system variable 保存的值,它存储绘图创建时的 Julian 日期时间值。
您从我的程序发布的代码正在使用 DIESEL edtime
function within a menu command expression.
格式化这个 Julian 日期时间值
如果你想要原始的 Julian 值,你可以简单地使用:
(getvar 'tdcreate)
可以使用 rtos
格式化为字符串,即:
(rtos (getvar 'tdcreate) 2 16)
我的代码有点问题。我想显示来自 autocad 格式的时间和日期。例如,autocad 中的 tdcreate 命令显示 2458753.59648148,但此代码显示在输出文件 26 September 2019 14:18:55:999 中。我不知道哪里错了。我想出现 2458753.59648148 。
(progn
(foreach item
'(
("Current time:" "DATE" "DD MONTH YYYY HH:MM:SS:MSEC")
("Created:" "TDCREATE" "DD MONTH YYYY HH:MM:SS:MSEC")
("Last updated:" "TDUPDATE" "DD MONTH YYYY HH:MM:SS:MSEC")
("Total editing time:" "TDINDWG" "HH:MM:SS:MSEC")
("Elapsed timer:" "TDUSRTIMER" "HH:MM:SS:MSEC")
)
(write-line
(strcat
(PadRight (car item) " " 24)
(apply 'FormatDate (cdr item))
)
openfile
)
)
(close openfile)
(startapp "notepad" filename)
)
(princ (strcat "\nUnable to Write to " filename))
)
(princ)
)
(defun PadRight ( string char lengtth )
(if (< (strlen string) lengtth)
(PadRight (strcat string char) char lengtth)
string
)
)
(defun GetUniqueFilename ( seed / count file flist )
(if (findfile (setq file seed))
(progn
(setq count 1
flist (fnsplitl seed)
)
(while
(findfile
(setq file
(strcat
(car flist)
(cadr flist)
"(" (itoa (setq count (1+ count))) ")"
(caddr flist)
)
)
)
)
)
)
file
)
(defun FormatDate ( sysvar format )
(menucmd (strcat "m=$(edtime,$(getvar," sysvar ")," format ")"))
)
在 AutoCAD 中,TDCREATE
命令仅返回由 TDCREATE
system variable 保存的值,它存储绘图创建时的 Julian 日期时间值。
您从我的程序发布的代码正在使用 DIESEL edtime
function within a menu command expression.
如果你想要原始的 Julian 值,你可以简单地使用:
(getvar 'tdcreate)
可以使用 rtos
格式化为字符串,即:
(rtos (getvar 'tdcreate) 2 16)