linx1314 发表于 2009-7-28 20:48:00

[求助]标注管长插件优化

<p>本人在网上找到这个标注管长和管径的程序,但由于联系不到原设计者,故在这里发帖请求大家优化,请原设计者谅解!我要实现如下的优化:1、我不要标管径;2、我希望标注的管长格式为“L=Xm”(X为数据)且数据标注在线上方;3、希望管长可以自己选择保留一位小数点或两位小数点。谢谢!可以在线联系我,QQ262022875</p><p></p><p>;同时标注管径和管长的程序<br/>;*****************参数初始化**********************<br/>(terpri)<br/>(prompt "程序初始化......")<br/>(terpri)<br/>(setq bl (if(setq bl (getreal "输入出图比例&lt;1:100&gt;1:")) bl 100));出图比例为1/bl<br/>(setq gao (* bl 2.5));根据比例计算字高。<br/>(setq tg (strcat "标注文字高度&lt;" (rtos gao) "&gt;"))<br/>(setq gao (if(setq xxx (getreal tg)) xxx gao));改变字高。<br/>(initget 1 "Y y n N")<br/>(setq xxx (getkword "是否标出管长?&lt;y/n&gt;:"))<br/>;*************初始化完毕********************<br/>(defun c:bz (/ jl pt1 pt2 ts ag wz du dnwz lwz dnin dnout jlout)<br/>&nbsp;&nbsp; (setq pt1 (getpoint "选择管段起点:"))<br/>&nbsp;&nbsp; (terpri);换行<br/>&nbsp;&nbsp; (setq pt2 (getpoint "选择管段末端:"))<br/>&nbsp;&nbsp; (terpri);换行<br/>&nbsp;&nbsp; (setq dn (if(&gt; dn 0) dn 100))<br/>&nbsp;&nbsp; (setq ts (strcat "输入管径&lt;" (itoa dn) "&gt;:"));将"输入管径&lt;默认管径&gt;:"负值给ts<br/>&nbsp;&nbsp; (setq dn (if(setq dnin (getint ts)) dnin dn));输入新的管径,回车取默认值(即上次运行的值)<br/>&nbsp;&nbsp; (setq ag (angle pt1 pt2));计算管线的斜率<br/>&nbsp;&nbsp; (setq jl (distance pt1 pt2));计算管线的长度<br/>&nbsp;&nbsp; (setq wz (- (/ jl 2) (* 2 gao)))<br/>&nbsp;&nbsp; (setq wz (polar pt1 ag wz));wz为管线的中点 <br/>&nbsp;&nbsp; (setq ag (if(and (&gt; ag (/ pi 2)) (&lt; ag (* pi 1.5))) (- ag pi) ag));将ag调整到0~pi&nbsp; <br/>&nbsp;&nbsp; (setq dnwz (polar wz (+ ag (/ pi 2)) (* 1.5 bl)));dnwz为管径标注的位置<br/>&nbsp;&nbsp; (setq lwz (polar wz (- ag (/ pi 2)) (* 4.0 bl)));lwz为管长标注的位置<br/>&nbsp;&nbsp; (setq dnout (strcat "DN" (itoa dn)));dnout为输出管径的字符串<br/>&nbsp;&nbsp; (setq jlout (strcat "L" (rtos (/ jl 1000.0))));jlout为输出管长的字符串&nbsp; <br/>&nbsp;&nbsp; (setq du (/ (* ag 180) pi));将管线斜率ag转换为度,负给du<br/>&nbsp;&nbsp; (setq wdpt1 (polar wz 2.356 100))<br/>&nbsp;&nbsp; (setq wdpt2 (polar wz -0.785 100));wdpt1,wdpt2为放大标注位置矩形对角两点<br/>&nbsp;&nbsp; (command "zoom" wdpt1 wdpt2)<br/>&nbsp;&nbsp; (command "text" dnwz gao du dnout);输出管径 <br/>&nbsp;&nbsp; (cond<br/>&nbsp;&nbsp;&nbsp;&nbsp; ((= xxx "y")(command "text" lwz gao du jlout));输出管长<br/>&nbsp;&nbsp;&nbsp;&nbsp; ((= xxx "Y")(command "text" lwz gao du jlout));输出管长<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp; (command "zoom" "previous")<br/>&nbsp;&nbsp; (princ);静默退出<br/>)<br/>;启动时在命令行要显示的内容<br/>&nbsp;&nbsp; (terpri)<br/>&nbsp;&nbsp; (prompt "\本程序由城市水手编写,有不足的地方请来信<a href="mailto:mesgi@163.net">mesgi@163.net</a>")<br/>&nbsp;&nbsp; (terpri)<br/>&nbsp;&nbsp; (prompt "管长管经标注程序加栽完毕,启动命令bz")<br/>&nbsp;</p>

linx1314 发表于 2009-7-29 20:52:00

<p>现在在做总图啊,急用啊!请高手出来解决下啊!谢谢!</p>

gao051525 发表于 2012-6-2 09:08:15

linx1314 发表于 2009-7-29 20:52 static/image/common/back.gif
现在在做总图啊,急用啊!请高手出来解决下啊!谢谢!

我也想得到这么好的程序,帮顶!!!

gao051525 发表于 2012-6-3 18:23:08

再帮忙顶一下,一定要顶出高手

阳光动力 发表于 2012-6-18 14:46:29

很好的程序,收藏了。
页: [1]
查看完整版本: [求助]标注管长插件优化