本帖最后由 yjtdkj 于 2021-8-5 14:57 编辑
哈哈哈,找到原因了,还真不是我改动的原因,就是原函数少了330组码。更新的代码贴在下面- ;; Group Entities - Lee Mac
- ;; Creates a Group with a given name containing all entities in the supplied list
- ;; grp - [str] Group name (use "*" for an anonymous group)
- ;; lst - [lst] List of entities to add to group
- ;; sel - [bol] If T, group is selectable
-
- (defun LM:groupentities ( grp lst sel / dic enx gde gdx tmp )
- (if (setq dic (cdr (assoc -1 (dictsearch (namedobjdict) "acad_group"))))
- (if (setq gdx (dictsearch dic grp)
- gde (cdr (assoc -1 gdx))
- )
- (progn
- (entmod (append gdx (mapcar '(lambda ( x ) (cons 340 x)) lst)))
- (foreach ent lst
- (setq enx (entget ent)
- tmp (member '(102 . "{ACAD_REACTORS") enx)
- )
- (if tmp
- (setq tmp
- (vl-list*
- (car tmp)
- (cons 330 gde)
- (cdr tmp)
- )
- )
- (setq tmp
- (vl-list*
- '(102 . "{ACAD_REACTORS")
- (cons 330 gde)
- '(102 . "}")
- (cdr (member (assoc 5 enx) enx))
- )
- )
- )
- (entmod (append (reverse (member (assoc 5 enx) (reverse enx))) tmp))
- )
- grp
- )
- (if
- (and
- (setq gde
- (entmakex
- (list
- '(000 . "GROUP")
- '(102 . "{ACAD_REACTORS")
- (cons 330 dic)
- '(102 . "}")
- (cons 330 dic)
- '(100 . "AcDbGroup")
- (if (wcmatch grp "`*") '(070 . 1) '(070 . 0))
- (if sel '(071 . 1) '(071 . 0))
- )
- )
- )
- (if (wcmatch grp "`*")
- (if (entmod (append (entget dic) (list '(3 . "*") (cons 350 gde)))) ;; thanks vk/rjp
- (setq grp
- (cdadr
- (member
- (cons 350 gde)
- (reverse (entget dic))
- )
- )
- )
- )
- (dictadd dic grp gde)
- )
- )
- (LM:groupentities grp lst sel)
- )
- )
- )
- )
- (defun c:test ( / grp idx lst sel )
- (while
- (not
- (or (wcmatch (setq grp (getstring t "Specify group name: ")) "`*,")
- (snvalid grp)
- )
- )
- (princ "\nGroup name invalid.")
- )
- (if (and (/= "" grp) (setq sel (ssget )))
- (progn
- (repeat (setq idx (sslength sel))
- (setq lst (cons (ssname sel (setq idx (1- idx))) lst))
- )
- (LM:groupentities grp lst t)
- )
- )
- )
|