明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2092|回复: 6

[源码] 日期

[复制链接]
发表于 2020-5-28 21:59:30 | 显示全部楼层 |阅读模式
(defun c:rq (/ tmp cy cm cd hh mm ss ms txt pt1)
  (setq tmp (rtos (getvar "cdate") 2 16));系统当前时间
  (setq     
    cy (rtos (atof (substr tmp 1 4)) 2 0);年
    cm (rtos (atof (substr tmp 5 2)) 2 0);月
    cd (rtos (atof (substr tmp 7 2)) 2 0);日
  )
  (setq txt (strcat " " cy "年"cm "月" cd "日"))
  (command "color" "magenta" "y")

  (setq pt1 (getpoint "\n\t放置点 : "))
  (command "text" "j" "mc" pt1 "0" txt)
  (princ)
)
发表于 2020-5-29 21:26:39 | 显示全部楼层
试试 (setq txt (menucmd  "m=$(edtime,$(getvar,DATE),yyyy年mo月dd日)"))
发表于 2020-5-30 04:27:51 | 显示全部楼层
本帖最后由 lisperado 于 2020-5-31 01:30 编辑

建议:
(cons 1 (menucmd  "M=$(edtime,0,YYYY年MO月DD日)") )

既然你是以substr cdate思路,建议mapcar可省略多余变量
而entmake以dxf 11 72 73 代替 "Justify" "M" "C" ,dxf 62 代替颜色

示范:
  1. (defun c:rq (/ % p)
  2.   (if (setq % (rtos (getvar 'cdate) 2 0)
  3.             p (getpoint "\n文本放置点 :")
  4.             )
  5.      (entmake (list '(0 . "TEXT")'(40 . 2.5)'(62 . 6)'(72 . 1)'(73 . 2)(cons 10 p)(cons 11 p)
  6.                    (cons 1
  7.                          (apply        'strcat
  8.                                 (mapcar        '(lambda (a b) (strcat (apply 'substr (cons % a)) b))
  9.                                         '((1 4) (5 2) (7 2))
  10.                                         '("年" "月" "日")
  11.                                         )
  12.                                 )
  13.                          )
  14.                    )
  15.              )
  16.     (princ "\n退出?")
  17.     )
  18.   (princ)
  19.   )



发表于 2020-5-30 11:46:38 | 显示全部楼层
如何让图里的日期做到和时间同步,自动更新

点评

字段  发表于 2020-5-30 12:57
发表于 2020-5-31 01:19:55 | 显示全部楼层
本帖最后由 lisperado 于 2020-5-31 01:28 编辑
BUBUBA918 发表于 2020-5-30 11:46
如何让图里的日期做到和时间同步,自动更新

命令: UPDATEFIELD 更新同步

请参考之前entmake
  1. '( 1 . "%<\\AcVar Date \\f \"%#c\">%" )
  2. ;默认根据区域格式
  3. ;Sunday, May 31, 2020 1:10:52 AM

  4. '( 1 . "%<\\AcVar Date \\f \"yyyy\U+5E74MM\U+6708dd\U+65E5\">%" )
  5. ;2020年5月31日

  6. '( 1 . "%<\\AcVar Date \\f \"yyyy年MM月dd日\">%" )
  7. ;2020年5月31日

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-17 22:57 , Processed in 0.172273 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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