批量更新圆的半径
;;;代码功能:批量更新圆的半径.lsp;;;代码含有多选对象批量单处理
;;;代码含有多选特定对象
;;;代码含有命令行显示处理结果
;;;春婵写于20231103
(defun c:tt (/ newr ss n i ngc_ss)
(setq newr (getreal "输入新半径:"));;;程序开始
(setq ss (ssget '((0 . "CIRCLE"))));;;取得圆选择集ss
(setq n (sslength ss))
(setq i 0)
(while (< i n)
(progn
(setq ngc_ss (ssname ss i));;;取得选择集内第0个图元名称
(Vlax-Put-Property (Vlax-Ename->Vla-Object ngc_ss) 'Radius newr);;;这里的newr是新的半径
(setq i (1+ i));;;while循环条件
);;;end progn
);;;endwhile
(princ (strcat "\n共更新了<"(itoa n)">个圆,新半径="(rtos newr)))
(princ)
)
源码和上面的是一样的,代码包含基础处理,学习备用
(defun c:tt ()
"批量更新圆或圆弧的半径"
(setq rr (Ureal 7 "" "新半径" rr))
(while (setq ss (ssget '((0 . "CIRCLE,ARC"))))
(xyp-SubUpd ss 40 rr)
)
(princ)
) xyp1964 发表于 2023-11-4 09:52
(defun c:tt ()
"批量更新圆或圆弧的半径"
(setq rr (Ureal 7 "" "新半径" rr))
(defun c:11 ()
"批量更新圆或圆弧的半径"
(setq rr (getreal "输入新半径:"))
(while (setq ss (ssget '((0 . "CIRCLE,ARC"))))
(xyp-SubUpd ss 40 rr)
)
(princ)
)
(defun xyp-SubUpd (ename code val / ent x y i s1)
(cond
((= (type ename) 'ENAME)
(setq ent (entget ename))
(if (and (= (type code) 'LIST) (= (type val) 'LIST))
(mapcar '(lambda (x y) (xyp-SubUpd ename x y)) code val)
(progn (if (= (xyp-dxf code ename) nil)
(entmod (append ent (list (cons code val))))
(entmod (subst (cons code val) (assoc code ent) ent))
)
(entupd ename)
)
)
)
((= (type ename) 'PICKSET)
(setq i -1)
(while (setq s1 (ssname ename (setq i (1+ i))))
(xyp-SubUpd s1 code val)
)
)
((= (type ename) 'LIST)
(foreach s1 ename (xyp-SubUpd s1 code val))
)
)
ename
)
(defun xyp-dxf (code ename / ent lst a)
(if (= (type code) 'list)
(progn (setq ent (entget ename))
(setq lst nil)
(foreach a code
(setq lst (cons (list a (cdr (assoc a ent))) lst))
)
(reverse lst)
)
(progn (if (= code -3)
(progn (cdr (assoc code (entget ename '("*")))))
(progn (cdr (assoc code (entget ename))))
)
)
)
) hhh454 发表于 2023-11-4 13:49
需要加载院长的自定函数,论坛里面有
是这个函数吗?
(defun xyp-SubUpd (ename code val / ent x y i s1)
(cond ((= (type ename) 'ENAME)
(setq ent (entget ename))
(if (and (= (type code) 'LIST) (= (type val) 'LIST))
(mapcar '(lambda (x y) (xyp-SubUpd ename x y)) code val)
(progn
(if (= (xyp-dxf code ename) nil)
(entmod (append ent (list (cons code val))))
(entmod (subst (cons code val) (assoc code ent) ent))
)
(entupd ename)
)
)
)
((= (type ename) 'PICKSET)
(setq i -1)
(while (setq s1 (ssname ename (setq i (1+ i))))
(xyp-SubUpd s1 code val)
)
)
((= (type ename) 'LIST)
(foreach s1 ename (xyp-SubUpd s1 code val))
)
)
ename
) 很实用,小白一枚,向大佬学习 感谢楼主分享 xyp1964 发表于 2023-11-4 09:52
(defun c:tt ()
"批量更新圆或圆弧的半径"
(setq rr (Ureal 7 "" "新半径" rr))
感谢大佬分享 xyp1964 发表于 2023-11-4 09:52
(defun c:tt ()
"批量更新圆或圆弧的半径"
(setq rr (Ureal 7 "" "新半径" rr))
版主2024,用不了,AutoCAD 变量设置被拒绝: "osmode" nil vista228 发表于 2023-11-4 13:21
版主2024,用不了,AutoCAD 变量设置被拒绝: "osmode" nil
需要加载院长的自定函数,论坛里面有 感谢楼主分享 hhh454 发表于 2023-11-4 13:49
需要加载院长的自定函数,论坛里面有
好的,谢谢楼主 hhh454 发表于 2023-11-4 13:49
需要加载院长的自定函数,论坛里面有
没有找到这个函数啊。xyp-SubUpd