Jump to content

Recommended Posts

Posted (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 by SLW210
Added Code Tags!
Posted

In the future please use code tags for your code. (<> in the editor toolbar)

Posted (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 by rlx
  • Like 1
Posted

Work beautifully. Thank you rlx. Great quality of life improvement at work for me.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...