【K:GetWebTime】获取网络时间并格式化
函数来自此贴,仅作优化:http://bbs.mjtd.com/forum.php?mo ... %CD%F8%C2%E7&page=1;获取网页URL的网络时间,如果不成功返回Nil
;(K:GetWebTime "https://www.baidu.com" "Date")
(defun K:GetWebTime (URL Headers / obj RtnVar)
(if (setq obj (vlax-create-object "winhttp.winhttprequest.5.1"))
(progn
(setq RtnVar (vl-catch-all-apply
'(lambda ()
(vlax-invoke-method obj "open" "head" URL :vlax-false)
(vlax-invoke obj "send")
(if (= 200 (vlax-get-property obj "status"))
(mapcar
'(lambda (h / r)
(setq r (vl-catch-all-apply 'vlax-invoke-method (list obj "getresponseheader" h)))
(cons h (if (not (vl-catch-all-error-p r)) (progn r)))
)
(list Headers)
)
)
)
)
)
(vlax-release-object obj)
(if (and RtnVar (not (vl-catch-all-error-p RtnVar))) ;不是错误
(cdar RtnVar)
)
)
)
)
;根据分隔符拆分字符串@LeeMac
(defun K:STR->Lst (STR Del / len Lst pos)
(setq len (1+ (strlen Del)))
(while (setq pos (vl-string-search Del STR))
(setq Lst (cons (substr STR 1 pos) Lst)
STR (substr STR (+ pos len))
)
)
(reverse (cons STR Lst))
)
;格式化获取到的网络时间OriSTR
(defun K:FmtWebTime (OriSTR / STRLst Wek Date Moth Year CurTim)
(if (and OriSTR (setq STRLst (K:STR->Lst OriSTR " ")))
(progn
(setq Wek (strcase (substr (nth 0 STRLst) 1 3)));只要前三个字母
(setq Date (nth 1 STRLst)
Moth (strcase (nth 2 STRLst))
Year (nth 3 STRLst)
)
(setq CurTim (nth 4 STRLst));当前时间
(setq Moth
(cdr
(assoc Moth
(list
(cons "JAN" "01")
(cons "FEB" "02")
(cons "MAR" "03")
(cons "APR" "04")
(cons "MAY" "05")
(cons "JUN" "06")
(cons "JUL" "07")
(cons "AUG" "08")
(cons "SEP" "09")
(cons "OCT" "10")
(cons "NOV" "11")
(cons "DEC" "12")
)
)
)
);几月份
(setq Wek
(cdr
(assoc Wek
(list (cons "MON" "01")
(cons "TUE" "02")
(cons "WED" "03")
(cons "THU" "04")
(cons "FRI" "05")
(cons "SAT" "06")
(cons "SUN" "07")
)
)
)
);周几
)
)
(if OriSTR (progn (strcat Year Moth Date)));输出年月日
)
用法:
(K:FmtWebTime (K:GetWebTime "https://www.baidu.com" "Date"))
感谢大佬分享 怎么用啊?
插件加密的一种方式
感谢大佬分享 ;可用于指定变化颜色的色号在255内且尾数不是6789随时间变化生成的自定义函数
(defun lsp20230905();自定义函数开始
(setq SJ1 (menucmd "M=$(edtime,$(getvar,date),SS)"))
(setq SJ11 (atoi SJ1));(atoi x)将字符串转换成整数
(setq SJ12 (* SJ11 0.1));让个位数成为小数点后面的数值
(setq SJ13 (fix SJ12));去除小数点后面得出0~5的数值(提取ss的十位数)
(setq SJ2 (menucmd "M=$(edtime,$(getvar,date),SS)"))
(setq SJ21 (atoi SJ2));(atoi x)将字符串转换成整数
(setq SJ22 (rem SJ21 10));余数相当于提取ss的个位数
(setq SJ23 (* SJ22 10));为实现十位数做准备
(setq SJ3 (+ SJ21 1));防止百位与十位数一致利用ss的十位数作为百位数的基础
(setq SJ31 (* SJ3 0.3));为实现百位数做准备
(setq SJ32 (fix SJ31));去除小数点后
(setq SJ33 (* SJ32 10));为实现百位数做准备
(setq SJSJ (+ SJ33 SJ23 SJ13))
(if (>= SJSJ 255)(setq SJSJ1 253) (if (= SJSJ 0)(setq SJSJ1 6) (setq SJSJ1 SJSJ)))
;如果SJSJ大于255(255是纯白色还是会出现类同不能立即出现变色效果故此令其等于253,如果生成0也是白色故此令其等于6)
);自定义函数结束 (defun c:FD ()
;(princ "点取起点坐标后画线QWQ")
;(command pause)
(command "-color" (lsp20230905)) ;设置当前绘图颜色为随机色
(command "pline" )
(while (/= (getvar "cmdactive") 0) ;用于连接空格后的命令
;(princ "点取起点后画多段线QWQ")
(command pause))
(command "-color" "bylayer");恢复当前绘图颜色为随层
(princ "点取起点后画多段线QWQ")
(princ)
) 本帖最后由 寒潮大冬瓜 于 2024-8-2 17:17 编辑
挺不错的!只是一边画图一边不同的颜色!辨识度很高
页:
[1]