- 积分
- 4533
- 明经币
- 个
- 注册时间
- 2007-10-19
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 wudechao 于 2025-4-17 13:18 编辑
感谢baitang36大师提供用纯lisp实现打印任意尺寸pdfhttp://bbs.mjtd.com/thread-189458-1-1.html和受高飞鸟的powershell用法的启示http://bbs.mjtd.com/forum.php?mod=viewthread&tid=192194&highlight=powershell,在打印的同时如何实现带天正对象的图纸拆分为单个dwg图(我们这边审图需要提供单文件pdf+对应的dwg)转为T3低版本,而且转t3图纸尺寸标注不完美,转换后标注尺寸可能满天飞,同时天正转低版本命令带对话框,无法实现打印同时自动拆分。解决办法就是拆图时候把天正设置参数里天正对象改为代理模式(没有变量控制这个参数,手工在对话框修改),代理模式下文件变的巨大,我测试一个4MB的图纸,改为代理模式后变成18MB,文件巨大带来电脑读写变慢,解决思路:平时画图为非代理模式,打印拆图时候改为代理模式,打印拆图后恢复原来的非代理模式。矛盾出现了:天正参数设置没有变量控制,参数用二进制文件保存至天正目录下sys\config.ini,如何修改?用二进制编辑器搜索config.ini 发现十六进制数值618CFE56625F01为代理,618CFE56625F00为非代理,lisp无法修改二进制文件,受高飞鸟文章启发,那就用powershell,我不懂powershell,在ai帮助下,反复修改3天,居然成功了!给大家分享。三个函数,函数path-tangent-config为天正目录下config.ini,函数xgpz就是修改是否为代理,函数proxy-isno判断原来的设置是否设置为代理模式。天正建筑T20v3`天正建筑T30V1.0测试通过,其它版本没有找到安装文件无法测试。天正建筑2014不知道是不是破解原因,网上的破解无法保存为代理对象。
(defun path-tangent-config (/ path-tangent path-config)
(if (member (strcase "tch_initstart.arx") (mapcar
'strcase
(arx)
)
);是否是天正建筑
(progn
(setq path-tangent (strcat (substr (findfile "tch_initstart.arx") 1 (1+ (vl-string-position 92
(vl-string-right-trim "\\tch_initstart.arx"
(findfile "tch_initstart.arx")
) nil t
)
)
) "SYS"
)
);天正下目录下的sys路径
(if (wcmatch path-tangent "*2014*")
(alert "你在使用的天正2014系列,该版本有缺陷,天正对象无法保存为代理对象,拆分的dwg图无法在未安装天正软件的机器上显示,请升级高版本的天正软件。")
)
(setq path-config (strcat path-tangent "\\" "config.ini"))
(if (findfile path-config)
(setq path path-config)
(setq path nil)
)
)
(setq path nil)
)
path
)
(defun xgpz (path-config tst / path-tangent path-config wsh mycommand mycommand1 mycommand2-1 mycommand2-2 mycommand3);修改天正建筑代理图像是否保存,config.ini文件,若tst为真,00改01
(vl-load-com)
(setq wsh (vlax-create-object "WScript.Shell"))
(setq mycommand1 (strcat "powershell.exe " "$p=\'" path-config "\'\;$b=[IO.File]::ReadAllBytes($p)\;0..($b.Count-7)|%{if(-join($b[$_..($_+6)]|%{\"$($_.ToString(\'X2\'))\"}) -eq\'618CFE56625F"))
(setq mycommand2-1 (strcat "01\'){$b[$_+6]=0"))
(setq mycommand2-2 (strcat "00\'){$b[$_+6]=1"))
(setq mycommand3 (strcat "}}\;[IO.File]::WriteAllBytes($p,$b)"))
(if tst
(setq mycommand (strcat mycommand1 mycommand2-2 mycommand3))
(setq mycommand (strcat mycommand1 mycommand2-1 mycommand3))
)
(vlax-invoke wsh 'run mycommand 0 1)
(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
(command "TLoadConfig");这句很关键,修改后要加载才生效
(vlax-release-object wsh)
)
(defun proxy-isno (path-config / pscmd resultfile result wsh f)
(vl-load-com)
(setq pscmd (strcat "powershell -command " "[bool](-join([IO.File]::ReadAllBytes('" path-config
"')|%{'{0:X2}'-f$_}) -match '618CFE56625F01')| Out-File $env:TEMP\\proxy_result.txt -Encoding Default"
)
)
(setq wsh (vlax-create-object "wscript.shell"))
(vlax-invoke wsh "run" pscmd 0 1)
(setq resultfile (strcat (getenv "TEMP") "\\proxy_result.txt"))
(while (not (findfile resultfile))
(while (not (findfile resultfile))
(command "_.delay" 100)
)
)
(setq f (open resultfile "r"))
(setq result (read-line f))
(close f)
(vl-file-delete resultfile)
(cond
((= result "True")
(setq tst t)
)
((= result "False")
(setq tst nil)
)
(t
(princ "\n文件不存在,无法判断是否是代理模式")
)
)
tst
)
|
评分
-
查看全部评分
|