AutoCAD LISP以圆心为中点,圆的缩放操作
2011-03-26 21:26 精诚所至 金石为开 阅读(705) 评论(0) 编辑 收藏 举报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)
)
代码完。
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)