Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I access Groups and query their entities with lisp ?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
smcfarren
621 Views, 3 Replies

How can I access Groups and query their entities with lisp ?

I need to manipulate various predefined groups of blocks - but don't know how to even get to them to get started.

Since groups are a non-graphical object (similar to fields I'm guessing) filtering ssget sees them but doesn't grab them!

 

Any Ideas ??

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: smcfarren

As a demo

;; a list with all Groups Enames
(setq grouplst (cdrs 350 (dictsearch (namedobjdict) "ACAD_GROUP")))
;; a list with all Enames in the first group
(setq first_group (cdrs 340 (entget (nth 0 grouplst))))

;; Michael Puckett
(defun cdrs (DxfKey ImpLst / TmpLst OutLst)
  (while (setq TmpLst (assoc DxfKey ImpLst))
    (setq OutLst (cons (cdr TmpLst) OutLst)
	  ImpLst (cdr (member TmpLst ImpLst))
    )
  )
  (reverse OutLst)
);; cdrs

HTH

Henrique

EESignature

Message 3 of 4
Lee_Mac
in reply to: smcfarren

You can also tackle the problem using Visual LISP by accessing the Groups collection, e.g.:

 

(defun groupobjects ( / lst rtn )
    (vlax-for grp (vla-get-groups (vla-get-activedocument (vlax-get-acad-object)))
        (vlax-for obj grp (setq lst (cons obj lst)))
        (setq rtn (cons (list (vla-get-name grp) lst) rtn)
              lst nil
        )
    )
    rtn
)
(vl-load-com) (princ)

 

Message 4 of 4
smcfarren
in reply to: smcfarren

Excellent help - thanks so much.  I've got a pile of regular drafting work building up on my desk right now,

but I really look forward to getting back to my lisp project becuase this is going to work very well.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost