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