barristann Posted November 9 Posted November 9 (edited) Hi all, How do I select groups in a window selection? I found this, but it select all groups in the drawing. I don't want all groups in the drawing, but only those in my window selection. ; Return: selection set of entities that make up all ; defined groups or nil (defun JRP:Groupss (/ Tmp Lst ss) (if (setq Tmp (massoc 350 (dictsearch (namedobjdict) "acad_group"))) (progn (setq ss (ssadd)) (foreach x Tmp (setq Lst (cons (massoc 340 (entget x)) Lst))) (foreach x Lst (foreach y x (ssadd y ss))) (if (> (sslength ss) 0) ss) ) ) ) (defun massoc (key alist / x nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) ) ) (reverse nlist) ) https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/ssget-group-selection/td-p/822248 Edited November 10 by SLW210 Added Code Tags! Quote
SLW210 Posted November 10 Posted November 10 In the future please use code tags for your code. (<> in the editor toolbar) Quote
rlx Posted November 10 Posted November 10 (edited) This creates a selectionset ss for you to use like : (sslength ss) or on command line : erase (eval ss) etc (defun c:test ( / r)(if (vl-consp (setq r (get)))(progn (setq ss (ssadd))(foreach e r (ssadd e ss))))) (defun get ( / s l) (if (setq s (ssget)) (foreach e (mapcar 'cadr (ssnamex s))(if (ggn e)(progn (redraw e 3)(setq l (cons e l)))))) l) (defun ggn (o / m g) (setq g (vla-get-groups (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type o) 'ENAME) (setq o (vlax-ename->vla-object o))) (vlax-for x g (vlax-for y x (if (equal o y)(setq m (cons (vlax-get x 'Name) m))))) m) Edited November 11 by rlx 1 Quote
barristann Posted November 12 Author Posted November 12 Work beautifully. Thank you rlx. Great quality of life improvement at work for me. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.