在CAD中用LISP实现原位放大数值
1、(defun c:fff(/ num) (princ"主要功能为原位数值放大") (setvar "cmdecho" 0) (if(= nil xsz像粜杵泳) (c:szcs)) (princ"\n当前放大系数为:")(princ xsz) (princ"\n如需重新设置请退出执行 szcs") (setq newlayer(tblsearch "layer" "WT")) (if(= newlayer nil) (command "layer" "n" "WT" "c" "2" "WT" "")) (setq nse(ssget)) (setq nse_len(sslength nse)) (setq nn 0) (repeat nse_len (setq nse_sub(ssname nse nn)) (setq nse_data(entget nse_sub)) (setq old_num_list(assoc 1 nse_data)) (setq old_layer_list(assoc 8 nse_data)); (setq num(cdr (assoc 1 nse_data))) (setq layer(cdr (assoc 8 nse_data))) (setq cal_old_num(atof num)) (setq cal_new_num(* xsz cal_old_num)) (setq new_num_list(cons 1 (rtos cal_new_num 2 1))) (setq new_lay_list(cons 8 "WT")) (setq nse_data(subst new_num_list old_num_list nse_data)) (setq nse_data(subst new_lay_list old_layer_list nse_data)) (entmod nse_data) (setq nn (+ nn 1)) (setq new_word(entlast)) ) (prin1) )(defun c:szcs() (setq xsz (getreal"放大系数")) )
2、执行_vlide命令,打开LISP编辑器,将第一步代码复制粘贴到编辑器中
3、点击加载命令
4、执行fff命令,如需重新设置放大系数执行SZCS