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

Lisp routine to get "GROUP NAME"

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1532 Views, 5 Replies

Lisp routine to get "GROUP NAME"

I need a basic lisp routine to get "Group name" by clicking on the objects
that group together using Group command !

Anyone have any thing that related to Group command I would like to know
too !

Thanks
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Hi Binny

Some basics:
[code]
(defun MeGetGroupName (Ent / CurDct CurGps)
(setq CurDct (dictsearch (namedobjdict) "ACAD_GROUP")
CurGps (cdar CurDct)
)
(apply 'append
(mapcar
'(lambda (l)
(if (member Ent (MeGetSubLst 340 (dictsearch CurGps l)))
(list l)
)
) (MeGetSubLst 3 CurDct)
)
)
)

(defun MeGetSubLst (Key Lst)
(mapcar
'cdr
(vl-remove-if-not
'(lambda (l) (equal (car l) Key))
Lst
)
)
)
[/code]
Use:
(MeGetGroupName (car (entsel)))

Cheers
--
Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
-------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient (or have received this e-mail in error) please
notify the sender immediately and destroy this e-mail. Any unauthorized
copying, disclosure or distribution of the material in this e-mail is strictly
forbidden.
Message 3 of 6
Anonymous
in reply to: Anonymous

Hi Jürg Menzi :

Thanks for posting the source code... I guess I was not clear in my first
post !!!

Autocad have a comand call "group", I manage to used this command and
successfully give name to each of the group.... Now In my drawing I have too
many group and I want to be able to get the group name by click on the
objects... I hope this make more sense to you... thank you


best regards

Binny


"Jürg Menzi "
<=?UTF-8?Q?J=C3=BCrg_Menzi_?=> wrote in message
news:4936376@discussion.autodesk.com...
Hi Binny

Some basics:
[code]
(defun MeGetGroupName (Ent / CurDct CurGps)
(setq CurDct (dictsearch (namedobjdict) "ACAD_GROUP")
CurGps (cdar CurDct)
)
(apply 'append
(mapcar
'(lambda (l)
(if (member Ent (MeGetSubLst 340 (dictsearch CurGps l)))
(list l)
)
) (MeGetSubLst 3 CurDct)
)
)
)

(defun MeGetSubLst (Key Lst)
(mapcar
'cdr
(vl-remove-if-not
'(lambda (l) (equal (car l) Key))
Lst
)
)
)
[/code]
Use:
(MeGetGroupName (car (entsel)))

Cheers
--
Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
-------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged information. If you
are
not the intended recipient (or have received this e-mail in error) please
notify the sender immediately and destroy this e-mail. Any unauthorized
copying, disclosure or distribution of the material in this e-mail is
strictly
forbidden.
Message 4 of 6
Anonymous
in reply to: Anonymous

Hi

I know enough about groups. The posted code are basic functions...
To use them as a program you've to write a small piece of code around:
[code]
(defun C:GetGroupName ( / CurEnt GrpLst)
(if (setq CurEnt (car (entsel)))
(if (setq GrpLst (MeGetGroupName CurEnt))
(alert
(strcat
"The selected object is member of group(s):"
(apply
'strcat
(mapcar '(lambda (l) (strcat "\n- " l)) GrpLst)
)
)
)
(alert "The selected object is not member of a group.")
)
)
(princ)
)

(defun MeGetGroupName (Ent / CurDct CurGps)
(setq CurDct (dictsearch (namedobjdict) "ACAD_GROUP")
CurGps (cdar CurDct)
)
(apply 'append
(mapcar
'(lambda (l)
(if (member Ent (MeGetSubLst 340 (dictsearch CurGps l)))
(list l)
)
) (MeGetSubLst 3 CurDct)
)
)
)

(defun MeGetSubLst (Key Lst)
(mapcar
'cdr
(vl-remove-if-not
'(lambda (l) (equal (car l) Key))
Lst
)
)
)
[/code]

Cheers
--
Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
Message 5 of 6
Anonymous
in reply to: Anonymous

Hi Jürg

Thank you for the enlightment... the lisp routine work great and modified it
a to make other lisp routine that I have work too.... THANK YOU VERY MUCH

Best regards
Binny


"Jürg Menzi "
<=?UTF-8?Q?J=C3=BCrg_Menzi_?=> wrote in message
news:4936453@discussion.autodesk.com...
Hi

I know enough about groups. The posted code are basic functions...
To use them as a program you've to write a small piece of code around:
[code]
(defun C:GetGroupName ( / CurEnt GrpLst)
(if (setq CurEnt (car (entsel)))
(if (setq GrpLst (MeGetGroupName CurEnt))
(alert
(strcat
"The selected object is member of group(s):"
(apply
'strcat
(mapcar '(lambda (l) (strcat "\n- " l)) GrpLst)
)
)
)
(alert "The selected object is not member of a group.")
)
)
(princ)
)

(defun MeGetGroupName (Ent / CurDct CurGps)
(setq CurDct (dictsearch (namedobjdict) "ACAD_GROUP")
CurGps (cdar CurDct)
)
(apply 'append
(mapcar
'(lambda (l)
(if (member Ent (MeGetSubLst 340 (dictsearch CurGps l)))
(list l)
)
) (MeGetSubLst 3 CurDct)
)
)
)

(defun MeGetSubLst (Key Lst)
(mapcar
'cdr
(vl-remove-if-not
'(lambda (l) (equal (car l) Key))
Lst
)
)
)
[/code]

Cheers
--
Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
Message 6 of 6
Anonymous
in reply to: Anonymous

You're welcome! Glad I could help.

Cheers
--
Jürg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report