45296876 发表于 2013-4-11 12:06:02

Gu_xl 发表于 2013-4-11 10:46 static/image/common/back.gif
(setq f (entnext (cdar (entget e))))
    (setq g (entget f))            
两句代码删掉!


entget f= entget (entnext f)= entget (entnext (ssname d (setq c (+ 1 c))))
原来是这意思,我发现了,你们的脑子咋那么好用呢,看来我的IQ是绝对有问题,版主不给出这个明灯的话,累死我也整不出来这条代码来。人比人,气死人啊。还需继续努力。谢谢版主了。

45296876 发表于 2013-4-11 12:33:24

(defun c:zg(/ a b c d e f g )

(setq a (getdist "\n输入字高:"))
(setq b (getdist "\n请输入字宽比例:"))
(setq c -1)
(setq d (ssget '((0 . "INSERT") (66 . 1))));获得包含'((0 . "INSERT") (66 . 1))两种信息的图块,也就是说获得有属性的图块
(repeat (sslength d)
   (setq e (ssname d (setq c (+ 1 c))))
   (setq f e)

(while (and
         (setq f (entnext f))
         (= "ATTRIB" (cdr (assoc 0 (setq g (entget f)))))
         )   

   (setq g (entmod (subst (cons 40 a) (assoc 40 g) g)))
         (entmod (subst (cons 41 b) (assoc 41 g) g))


(entupd e)
    );while闭括号
);repeat闭括号

(princ)
);defun闭括号
下面就是经超版指点所完成的批量修改属性块文字的字高与字宽程序

45296876 发表于 2013-4-11 15:01:45

Gu_xl 发表于 2013-4-11 09:29 static/image/common/back.gif
.
.
.


'((0 . "INSERT") (66 . 1))这句话去掉也可以吧。应该 对后面没什么影响吧,暂时对我选的属性块是没有影响。谢谢版主提醒。

ll_j 发表于 2013-4-11 16:32:21

45296876 发表于 2013-4-11 15:01 static/image/common/back.gif
'((0 . "INSERT") (66 . 1))这句话去掉也可以吧。应该 对后面没什么影响吧,暂时对我选的属性块是没有影响 ...

从运行效率来说,第一个entmod不需要。
从结构化而言,连续赋值只要一个setq就行了,多了虽然效果一样,但显得不专业了。
另,输入宽度比例最好使用initget(bit=2+4=6)和getreal进行。

zhangcan0515 发表于 2020-8-14 23:22:55

谢谢分享学习了,解决了我很多问题
页: 1 [2]
查看完整版本: 新问题 请教,还是属性块的问题。