本帖最后由 edata 于 2022-5-21 22:31 编辑
以前写了一个用于DCL版本基于MFC的二维码生成程序,有人说不能动态生成。
这不动态的他来了。
exe附件,例子解压到D盘,
2022-05-21更新附件,隐蔽运行
代码更新,添加边框,指定左上角点,单个方块大小
- (defun c:tt(/ wscript stdout wsreturn outstr pt n k lst ptbase h ptleftdown ptleftup ptrightdown ptrightup size w)
- (setq WScript (vlax-get-or-create-object "WScript.Shell"))
- (setq WSreturn (vlax-invoke WScript 'exec "\"D:\\QRencodeForLisp.exe\" \"明经通道\r\ncode by edata\r\n\""))
- (setq stdout (vlax-get WSreturn 'StdOut))
- (setq outstr (vlax-invoke stdout 'Readall))
- (setq lst(read outstr))
- (if (and lst (setq ptbase(getpoint "\n左上角点:")))
- (progn
- ;(setq ptbase '(0 0))
- (setq h(length lst) w(length (car lst)))
- ;;方块的大小
- (setq size 100.0)
- (setq ptLeftUp (polar ptbase (* pi 1.75) (* (sqrt 2.0) (* size 0.5))))
- (setq ptRightUp(polar ptLeftUp 0 (+ (* w size) size )))
- (setq ptLeftDown(polar ptLeftUp (* pi 1.5) (+ (* w size) size )))
- (setq ptRightDown(polar ptRightUp (* pi 1.5) (+ (* w size) size )))
- (mkFrame ptLeftUp ptLeftDown ptRightDown ptRightUp 16777215 size)
- (setq ptbase(polar (polar ptLeftUp 0 (* 0.5 size)) (* pi 1.5) size))
- (foreach n lst
- (setq pt ptbase)
- (foreach k n
- (if (= k 1) (mkpline pt 0 size) (mkpline pt 16777215 size))
- (setq pt(polar pt 0 size))
- )
- (setq ptbase(polar ptbase (* pi 1.5) size))
- )
- )
- )
- (princ)
- )
- (defun mkpline(pt col size)
- (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 420 col) (cons 90 2) (cons 10 pt) (cons 10 (polar pt 0 size))(cons 43 size)))
- )
- (defun mkFrame(p1 p2 p3 p4 col size / lst pt)
- (setq lst(list p1 p2 p3 p4))
- (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 420 col)(cons 90 (length lst))(cons 70 1)(cons 43 size))
- (mapcar '(lambda (pt)(cons 10 pt)) lst ))
- )
- )
-
-
效果:
历史版本
2022-05-20更新附件,会有闪现
测试代码
;;例子简单的生成黑白色二维码,可以根据需求。
;;本质上调用就是 exe路径 空格 字符串
;;字符串参数换行可以使用\r\n 符合windows回车换行标准
;;字符串参数建议使用转义包裹 \" ,防止参数中有空格导致参数截断
;;路径建议使用转义包裹 \" ,防止路径中有空格导致参数截断
;;注 源码中原来的链接地址在论坛代码高亮中会被转义,去掉了链接地址
- (defun c:tt(/ wscript stdout wsreturn outstr pt n k lst ptbase)
- (setq WScript (vlax-get-or-create-object "WScript.Shell"))
- (setq WSreturn (vlax-invoke WScript 'exec "\"D:\\QRencodeForLisp.exe\" \"明经通道\r\ncode by edata\r\n\""))
- (setq stdout (vlax-get WSreturn 'StdOut))
- (setq outstr (vlax-invoke stdout 'Readall))
- (setq lst(read outstr))
- (if lst
- (progn
- (setq ptbase '(0 0))
- (foreach n lst
- (setq pt ptbase)
- (foreach k n
- (if (= k 1) (mkpline pt 0) (mkpline pt 16777215))
- (setq pt(polar pt 0 1))
- )
- (setq ptbase(polar ptbase (* pi 1.5) 1))
- )
- )
- )
- (princ)
- )
- (defun mkpline(pt col)
- (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 420 col) (cons 90 2) (cons 10 pt) (cons 10 (polar pt 0 1))(cons 43 1)))
- )
生成结果:
识别结果
补充
命令行手工操作生成二维码列表值txt文件,
- QRencodeForLisp.exe "建设单位:明经通道\r\n设计单位:edata" >test.txt
|