时间插件
谁帮忙做一个时间插件功能如下
1.输入命令插入当前时间,格式2020/7/13
2.当下次打开图纸修改后,输入另一个命令后更新日期.
;;;---------------------------------------------------
(defun c:NMM (/ p sn en p1 nam ty e1 e2 st p2 p3 p4 ss )
(command "undo" "g")
(setq os (getvar "osmode") blp (getvar "blipmode"))
(setvar "blipmode" 0)
(graphscr)
(if (null text0)(setq text0 ""))
(setq sn (menucmd "M=$(edtime,$(getvar,date),YYYY/M/DD )"))
(setq st (menucmd "M=$(edtime,$(getvar,date),YYYY/M/DD )"))
(while(setq p (entsel "\n点取需要更新的日期:"))
(setq sn(car p)
en(entget sn)
p1(to 10)
nam (to 2)
ty(to 0)
)
(if (or (= "TEXT" ty) (= "INSERT" ty) (= "DIMENSION" ty))
(if (or (= "TEXT" ty) (= "DIMENSION" ty))
(progn
(setq e1 (subst (cons 1 st) (assoc 1 en) en))
(entmod e1)
) ;progn
(progn
(setq e1 (entget (entnext (cdr (car en)))))
(setq e1 (subst (cons 1 st) (assoc 1 e1) e1))
(entmod e1)
(entmod en)
(if (or (eq nam "PQ") (eq nam "PQ1"))
(progn
(setq e2 (entget (entnext (cdr (car e1)))))
(setq e2 (subst (cons 1 st) (assoc 1 e2) e2))
(entmod e2)
(entmod en)
)
)
) ;progn
)
(progn
(princ "n所選物體是")
(princ (cdr (assoc 0 en)))
(princ ", 不是文字或圖塊,請重新選擇:n")
)
)
) ;while
(setvar "blipmode" blp)
(terpri)
(command "undo" "end")
(princ)
)
(defun to (n)
(cdr (assoc n (entget sn)))
)
(DEFUN C:nm(/ OLDOS oldclay PT STA )
;;
(setq oldclay (getvar "CLAYER"))
(setq olderr *error*)
(setq *error* myerr)
(SETVAR "CMDECHO" 0)
(SETQ OLDOS (GETVAR "OSMODE"))
;;
(command "layer" "m" "00AC-nowtime" "c" 1 "00AC-nowtime" "L" "CONTINUOUS" "00AC-nowtime" "LW" "0.45" "00AC-nowtime" "")
(command ^c^c "layer" "p" "n" "00AC-nowtime""")
(command"style" "@@ZHJ-AC" "gbeitc.shx,hztxt.shx" "0" "0.8" "" "" "")
(SETVAR "OSMODE" 0)
(while(SETQ PT (GETPOINT"\n請指定插入點:"))
(SETQ znowtime (menucmd "M=$(edtime,$(getvar,date),DDD\", \"D MON YYYY)"))
(SETQ znowtime (menucmd "M=$(edtime,$(getvar,date),YYYY/M/DD )"))
;(SETQ znowtime (menucmd "M=$(edtime,$(getvar,date),YYYY\"年\"M\"月\"DD\"日\" hh\"?\"mm\"分\"ss\"秒\")"))
(command "text" "s""@@ZHJ-AC""j" "m" PT 300 0 znowtime)
)
(SETVAR "OSMODE" OLDOS)
(SETVAR "CMDECHO" 1)
(setq *error* olderr)
(setvar "CLAYER" oldclay)
(PRIN1)
)
xj6019 发表于 2020-7-13 20:04
这是我这边的效果,建议忽略第一个插入吧,用你cad文件里面有的文字(单行文字),复制过去,用第二个代码刷 ...
非常感谢你的支持,我想要的效果是,当插入时间后,下次修改图纸了,希望能够一键更新所有的时间,如果一个一个时间选择有点慢,看看能不能再改改 求帮忙做一个~~~~~~~~~~~~~~~拜托个位高手做一个 拜托个位 拜托个位 http://bbs.mjtd.com/forum.php?mod=viewthread&tid=85021&highlight=%CA%B1%BC%E4
本帖最后由 lxl217114 于 2020-7-13 13:49 编辑
用字段就可以实现的
附件:
xj6019 发表于 2020-7-13 12:32
(DEFUN C:nm(/ OLDOS oldclay PT STA )
;;
(setq oldclay (getvar "CLAYER"))
好像不行,怎么回事?????? 上面是另外一个命令
页:
[1]
2