Author Topic: Finding the name of an Anonymous Group  (Read 2764 times)

0 Members and 1 Guest are viewing this topic.

nivuahc

  • Guest
Finding the name of an Anonymous Group
« on: April 21, 2005, 12:49:38 PM »
I've completely exhausted myself with this and I know it has to be something simple. I think that's what's killing me.

Say you created an anonymous group like this

Code: [Select]
-group;;*;;

Lucky you, now you have a group in your drawing called *A1 or something just like that.

Well that's the approach I take with our panelboard schedules (it's an electrical thing). Lots of information, easily edited, move it all in one big chunk. The contents of these groups I am creating is a mixture of attributed blocks, polylines, lines, text and mtext.

One of my users wants to change something for whatever reason... so the first thing they do is try to explode it. :x

If you are familiar with the way that groups work, you know what happens then. If not, I'll tell you. Since each item in the group is, basically, individual items (blocks, text, polylines, etc...) they are all 'sploded.

Take a look at this "before" picture



Now take a look at this "after" picture



Lovely.

Easy enough, un-grouping a group isn't all that difficult... then I think about the users here... and I want to make it as simple as clicking a button, selecting the group in question, and un-grouping it for them.

I cannot, for the life of me, figure out how to determine the name of a particular group with a user selection. When I select something in a group, I get the internal member of that group returned to me. So if I select a bit of text, I get text returned to me. I need the group name!!!! aarrrrrrggggghhhhh

I know this has to be possible... if you go through the group dialog and select "Find name" it has you select a group and it gives you the name... I want to be able to do this and, much like the pirate with a stearing wheel hanging from his belt buckle, it's driving me nuts!

Hopefully, I'm making at least a little sense and someone here can enlighten me.

Any takers?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Finding the name of an Anonymous Group
« Reply #1 on: April 21, 2005, 01:01:09 PM »
If you pass a vild entity name to this --

Code: [Select]
(defun GroupNames ( ename / key dct result )
    ;;  © Michael Puckett
    (setq
        key (cons 340 ename)
        dct (dictsearch (namedobjdict) "acad_group")
    )
    (while (setq dct (member (assoc 3 dct) dct))
        (if (member key (entget (cdadr dct)))
            (setq result (cons (cdar dct) result))
        )
        (setq dct (cddr dct))
    )
    (reverse result)
)

It will return a list of the group names the entity is a child of, innermost first, like ("*A1" "*A2" "*A3").

I forget when I wrote it, it was 1999 or 2000 I think, I'd have to check.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

nivuahc

  • Guest
Finding the name of an Anonymous Group
« Reply #2 on: April 21, 2005, 01:17:34 PM »
Am I missing something here?

Code: [Select]
Command: (setq xxx (entsel))

Select object: (<Entity name: 408acfa0> (6.97371 1.18797 0.0))

Command: (groupnames xxx)
nil

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Finding the name of an Anonymous Group
« Reply #3 on: April 21, 2005, 01:22:34 PM »
Perhaps --

Code: [Select]
(if (setq ename (car (entsel)))
    (GroupNames ename)
)

If it returns nil it means (a) you didn't pick an entity or (b) entity is not a member of any group.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
Finding the name of an Anonymous Group
« Reply #4 on: April 21, 2005, 02:58:50 PM »
I used to use groups and all group names were created by the name of the block being inserted, which also had a string with the drawing name in it that I would select. That string would be selected and the groups would be selectable or not selectable. Does that spur any ideas for you or make any sense?

nivuahc

  • Guest
Finding the name of an Anonymous Group
« Reply #5 on: April 21, 2005, 03:44:29 PM »
car, car, car, car, car, car, car.......

doh! :shock:

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Finding the name of an Anonymous Group
« Reply #6 on: April 22, 2005, 11:42:02 AM »
Did that code snip end up workin' for ya Chuck or did I not understand the question (a first of course)?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

nivuahc

  • Guest
Finding the name of an Anonymous Group
« Reply #7 on: April 22, 2005, 11:47:08 AM »
It worked perfectly Michael, thanks. And, true to form, it got me thinking of something else... sorry for not showing my gratitude sooner. :oops:

I just posted a thread on my new train of thought, which your code sparked.

Ain't ADHD grand? :D

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Finding the name of an Anonymous Group
« Reply #8 on: April 22, 2005, 12:00:43 PM »
No worries Chuck -- I'm known for going into lengthy explainations that have nothing to do with what the poster really asked so I thought I best ask. I come from a long line of tangentalists ya know.

:roll:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst