Author Topic: Q: AutoCAD groups in AutoLISP  (Read 3762 times)

0 Members and 1 Guest are viewing this topic.

Fuccaro

  • Guest
Q: AutoCAD groups in AutoLISP
« on: September 20, 2006, 12:49:59 AM »
In AutoCAD I can group some entities and assign a name to the group using the GROUP command. Can I decide inside of AutoLisp if the selected object belongs to a certain group? With other words: I would like to find out how are stored those group data and if I can access them from AutoLisp.
Can anyone help me? Thanks.

FengK

  • Guest
Re: Q: AutoCAD groups in AutoLISP
« Reply #1 on: September 20, 2006, 02:25:47 AM »
From Tony T

Code: [Select]
(defun getgroups (object / data res obj)
(setq data
(member '(102 . "{ACAD_REACTORS")
(entget (vlax-vla-object->ename object))
)
)
(while (and (setq data (cdr data))
(not (equal (car data) '(102 . "}")))
)

(if (eq (caar data) 330)
(vl-catch-all-apply
'(lambda ()
(setq obj
(vlax-ename->vla-object (cdar data))
)
(if (eq (vla-get-ObjectName obj) "AcDbGroup")
(setq res (cons (vla-get-Name obj) res))
)
)
)
)
)
res
)

For more info. refer to this page:
http://discussion.autodesk.com/thread.jspa?messageID=5057420
« Last Edit: October 05, 2006, 06:14:58 AM by daron »

CADmium

  • Newt
  • Posts: 33
Re: Q: AutoCAD groups in AutoLISP
« Reply #2 on: October 05, 2006, 02:02:53 AM »
Some code to handle groups in ACAD you can find here in the fileattachement.
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

Patrick_35

  • Guest
Re: Q: AutoCAD groups in AutoLISP
« Reply #3 on: October 05, 2006, 09:10:28 AM »
Hi
a Exemple

Code: [Select]
(setq gr (vla-get-groups (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for g gr
  (princ (strcat "\nGroup : " (vla-get-name g)))
  (vlax-dump-object g)
  (princ)
)

@+