明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: hhh454

[源码] 批量更新圆的半径

[复制链接]
发表于 2023-11-6 00:26 | 显示全部楼层
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

)

评分

参与人数 1明经币 +1 收起 理由
xyp1964 + 1 赞一个!

查看全部评分

发表于 2023-11-7 22:35 | 显示全部楼层
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))))
           )
    )
  )
)
发表于 2023-11-7 22:36 | 显示全部楼层
LYC688 发表于 2023-11-7 22:35
(defun c:11 ()
  "批量更新圆或圆弧的半径"
  (setq rr (getreal "输入新半径:"))

感觉也不行
发表于 2023-11-7 22:41 | 显示全部楼层
LYC688 发表于 2023-11-7 22:35
(defun c:11 ()
  "批量更新圆或圆弧的半径"
  (setq rr (getreal "输入新半径:"))

院长的函数加在一起其实也挺长的呀
发表于 2023-11-7 23:17 | 显示全部楼层

感谢楼主分享,VERY GOOD
发表于 2023-11-14 09:41 | 显示全部楼层
很实用,小白一枚,向大佬学习
发表于 2023-11-18 10:14 | 显示全部楼层
我的2013  2024全可以用谢谢

点评

lisp源码几乎全版本通用  发表于 2023-12-5 21:01
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-18 12:59 , Processed in 0.153018 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表