AutoCAD LISP圆放大缩小操作,代码如下。
(defun c:cira()
(setvar "cmdecho" 0)
(setq cir (entsel "Select CIRCLE to <Scale 0.5>:"))
(setq cir_data (entget (car cir)))
(setq old_rad_list (assoc 40 cir_data))
(setq old_rr (cdr old_rad_list))
(setq new_rr (* old_rr 0.5))
(setq new_rad_list (cons 40 new_rr))
(setq cir_data (subst new_rad_list old_rad_list cir_data))
(entmod cir_data)
(prin1)
)
(defun c:cirb()
(setvar "cmdecho" 0)
(setq cir (entsel "Select CIRCLE to <Scale 2>:"))
(setq cir_data (entget (car cir)))
(setq old_rad_list (assoc 40 cir_data))
(setq old_rr (cdr old_rad_list))
(setq new_rr (* old_rr 2))
(setq new_rad_list (cons 40 new_rr))
(setq cir_data (subst new_rad_list old_rad_list cir_data))
(entmod cir_data)
(prin1)
)
(prompt "******<<C:CIRA>>******<<C:CIRB>>*******")
(prin1)
代码完。
修改一下,安指定值进行缩放,代码如下。
(defun c:cira()
(setvar "cmdecho" 0)
(setq cir (entsel "Select CIRCLE to <Scale>:"))
(setq a (getreal "\n请输入缩放系数:"))
(setq cir_data (entget (car cir)))
(setq old_rad_list (assoc 40 cir_data))
(setq old_rr (cdr old_rad_list))
(setq new_rr (* old_rr a))
(setq new_rad_list (cons 40 new_rr))
(setq cir_data (subst new_rad_list old_rad_list cir_data))
(entmod cir_data)
(prin1)
)
代码完。