这个代码错哪了啊?检查了很多遍都找不到原因
查了变量,前面都附了值,就是进入循环那里,ent开始就nil了,错误显示的是“错误: no function definition: ENTLENGTH”(defun c:9testa1()
(setvar "cmdecho" 0)
(setq p1 (getpoint"选择基点:"))
(setq p2 (getcorner p1 "\n选择要更改半径的圆"))
(if (> (car p1)(car p2))
(setq ss (ssget "C" p1 p2))
(setq ss (ssget "W" p1 p2))
)
(setq n 0 k 0)
(setq newr (getreal "输入新半径:"))
(repeat(sslength ss)
(setq ent(ssname ss n))
(setq ent_date (entget ent))
(setq ttype (cdr (assoc 0 ent_date)))
(if (= ttype "CIRCLE")
(sub_upd_rad)
)
(setq n (1+ n))
)
(princ (strcat "\n共更新了<"(itoa k)">个圆,新半径="(rtos newr)))
(prin1)
)
(defun c:sub_upd_rad()
(setq ent_date (subst (cons 40 newr) (assoc 40 ent_date) ent_date))
(entmod ent_date)
(setq k (1+ k))
)
(defun c:tt (/ r)
(if (and (setq r (getdist "\n输入或量取新半径:"))
(ssget '((0 . "CIRCLE")))
)
(vlax-for e (vla-get-activeselectionset (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-put-Radius e r)
)
)
) (defun c:9testa1()
(setvar "cmdecho" 0)
(setq p1 (getpoint "选择基点:"))
(setq p2 (getcorner p1 "\n选择要更改半径的圆"))
(if (> (car p1)(car p2))
(setq ss (ssget "C" p1 p2))
(setq ss (ssget "W" p1 p2))
)
(setq n 0 k 0)
(setq newr (getreal "输入新半径:"))
(repeat(sslength ss)
(setq ent(ssname ss n))
(setq ttype (cdr (assoc 0 (entget ent)))) ;另外,这里选择的时候可以用SSget过滤一下(自己摸索),直接选取圆,不要选择了再判断,可以更简洁高效
(if (= ttype "CIRCLE")
(progn
(sub_upd_rad ent newr) ;传参形式的函数调用
(setq k (1+ k)) ;计数放这里,子函数功能要单一化
)
)
(setq n (1+ n))
)
(princ (strcat "\n共更新了<"(itoa k)">个圆,新半径="(rtos newr)))
(princ)
)
;----------------------------------------
;自定义子函数,不要C:
(defun sub_upd_rad(ent r)
(setq ent_data (entget ent))
(setq ent_data (subst (cons 40 r) (assoc 40 ent_data) ent_data))
(entmod ent_data)
)
(defun c:tt ()
(defun SubUpd(e dxf val)
(entmod (subst (cons dxf val)(assoc dxf (entget e))(entget e)))
(entupd e)
)
(if (and (setq rr (getreal "\n输入新半径: "))
(setq p1 (getpoint "\n选择基点: "))
(setq p2 (getcorner p1 "\n对角点: "))
(setq ss (ssget "C" p1 p2 '((0 . "circle"))))
(setq i -1)
)
(while (setq s1 (ssname ss (setq i (1+ i))))(SubUpd s1 40 rr))
)
(princ)
)
自定义的子函数不是你这样玩的,建议用传参形式调用,不要用全局。 PS:你发错版块了。 Bao_lai 发表于 2023-11-1 00:15
(defun c:9testa1()
(setvar "cmdecho" 0)
(setq p1 (getpoint "选择基点:"))
十分感谢大佬解惑 、 Bao_lai 发表于 2023-11-1 00:19
PS:你发错版块了。
嗯,我也不太懂,下次注意。 批量更新圆的半径
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=188850&fromuid=363233
(出处: 明经CAD社区)
本帖最后由 d1742647821 于 2023-12-5 10:17 编辑
将你移动至lisp分区 d1742647821 发表于 2023-11-6 16:27
错在你发错了分区,批量修改圆半径,C#版,powerer by ifox
白老师有没研究过lisp的组码替换、vlisp的vla方法、c#方法效率差多少? 给你移动到lisp区了
页:
[1]
2