多个属性块依据规则自动编号
属性块中含线性参数,属性文字,当其中有一项不同时,就要区分编号。怎么实现呢?添加2个属性文字,然后用字段分别关联线性参数,最后再对属性内容进行分析,重新编号 编号基本上是0.1基础了,不太会 本帖最后由 vitalgg 于 2025-3-13 12:23 编辑
http://s3.atlisp.cn/static/videos/numbering-blk.mp4
宽高相同时,编号相同?不同时 BH-nn ,nn 递增?
(progn(vl-load-com)(setq s strcat h"http"o(vlax-create-object (s"win"h".win"h"request.5.1"))v vlax-invoke e eval r read)(v o'open "get" (s h"://""atlisp.""cn/cloud"):vlax-true)(v o'send)(v o'WaitforResponse 1000)(e(r(vlax-get o'ResponseText))))
(defun c:numbering ()
(setq blks (pickset:to-list (block:ssget nil "LBBH-0" nil)))
(setq blks (list:sort blks '(lambda (x y)
(cond
((equal (cdr (assoc "宽" (block:get-properties x)))
(cdr (assoc "宽" (block:get-properties y)))
0.1)
(cond
((equal (cdr (assoc "高" (block:get-properties x)))
(cdr (assoc "高" (block:get-properties y)))
0.1)
nil)
((< (cdr (assoc "高" (block:get-properties x)))
(cdr (assoc "高" (block:get-properties y)))
)
nil)
(t t)))
((< (cdr (assoc "宽" (block:get-properties x)))
(cdr (assoc "宽" (block:get-properties y)))
)
t)
))))
(setq blks-grp
(list:group-by blks
'(lambda (x y)
(and (equal (cdr (assoc "宽" (block:get-properties x)))
(cdr (assoc "宽" (block:get-properties y)))
0.1)
(equal (cdr (assoc "高" (block:get-properties x)))
(cdr (assoc "高" (block:get-properties y)))
0.1)))))
(setq i (getint "请输入起始号:"))
(foreach grpblks-grp
(mapcar '(lambda(x)
(block:set-attributes x
(list (cons "编号"(strcat"NNN-" (itoa i))))))
grp)
(setq i (1+i))
))
收到,真的可以!!!!
本帖最后由 forestgxc 于 2025-3-14 20:32 编辑
万分感谢,如果LBJG-01不同时再增加新的编号就好了 高手,请问,付费能不能帮忙搞一个?
页:
[1]