在CAD中用LISP实现原位放大数值

2025-10-24 09:34:04

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、点击加载命令

在CAD中用LISP实现原位放大数值

4、执行fff命令,如需重新设置放大系数执行SZCS

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢