Author Topic: nested ename list  (Read 7757 times)

0 Members and 1 Guest are viewing this topic.

Joe Burke

  • Guest
nested ename list
« on: October 07, 2008, 08:49:26 AM »
I've been banging my head on this.

(setq elst (nentsel "\nSelect nested object: "))
(setq nestlst (last elst))

Can nestlst be determined without using nentsel or nentselp?
IOW, a function which takes a nested ename argument and returns
the same list as nestlst.

My research on this question has not turned up a solution so far.
My attempts to code it looking at DXF codes 330 and 331 have failed.

TIA for any help.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: nested ename list
« Reply #1 on: October 07, 2008, 10:58:47 AM »
In ACAD2000
Code: [Select]
_$ (setq elst (nentsel "\nSelect nested object: "))
(setq nestlst (last elst))
(<Entity name: 1c9ae10> (792.505 94.0832 0.0) ((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) (777.399 89.6897 0.0)) (<Entity name: 1c9ae40>))
(<Entity name: 1c9ae40>)

_$ (setq e1 (car elst))
<Entity name: 1c9ae10>
_$ (setq el1 (entget e1))
((-1 . <Entity name: 1c9ae10>) (0 . "LINE") (330 . <Entity name: 1c9ad90>) (5 . "A1A2") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (39 . -0.76) (10 17.2207 3.86134 0.0) (11 13.0833 5.78647 0.0) (210 0.0 0.0 1.0))
_$ (setq e2 (cdr (assoc 330 el1)))
<Entity name: 1c9ad90>
_$ (setq el2 (entget e2))
((-1 . <Entity name: 1c9ad90>) (0 . "BLOCK_RECORD") (330 . <Entity name: 1c89008>) (5 . "A192") (100 . "AcDbSymbolTableRecord") (100 . "AcDbBlockTableRecord") (2 . "blk1") (360 . <Entity name: 1c9ad98>) (340 . <Entity name: 0>) (310 . "2800000020000000200000000100080000000000000400000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000C0DCC000F0CAA6000020400000206000002080000020A0000020C0000020E00000400000004020000040400000406000004080000040A0") (310 . "000040C0000040E00000600000006020000060400000606000006080000060A0000060C0000060E00000800000008020000080400000806000008080000080A0000080C0000080E00000A0000000A0200000A0400000A0600000A0800000A0A00000A0C00000A0E00000C0000000C0200000C0400000C0600000C0800000C0") (310 . "A00000C0C00000C0E00000E0000000E0200000E0400000E0600000E0800000E0A00000E0C00000E0E00040000000400020004000400040006000400080004000A0004000C0004000E00040200000402020004020400040206000402080004020A0004020C0004020E000404000004040200040404000404060004040800040") (310 . "40A0004040C0004040E00040600000406020004060400040606000406080004060A0004060C0004060E00040800000408020004080400040806000408080004080A0004080C0004080E00040A0000040A0200040A0400040A0600040A0800040A0A00040A0C00040A0E00040C0000040C0200040C0400040C0600040C08000") (310 . "40C0A00040C0C00040C0E00040E0000040E0200040E0400040E0600040E0800040E0A00040E0C00040E0E00080000000800020008000400080006000800080008000A0008000C0008000E00080200000802020008020400080206000802080008020A0008020C0008020E00080400000804020008040400080406000804080") (310 . "008040A0008040C0008040E00080600000806020008060400080606000806080008060A0008060C0008060E00080800000808020008080400080806000808080008080A0008080C0008080E00080A0000080A0200080A0400080A0600080A0800080A0A00080A0C00080A0E00080C0000080C0200080C0400080C0600080C0") (310 . "800080C0A00080C0C00080C0E00080E0000080E0200080E0400080E0600080E0800080E0A00080E0C00080E0E000C0000000C0002000C0004000C0006000C0008000C000A000C000C000C000E000C0200000C0202000C0204000C0206000C0208000C020A000C020C000C020E000C0400000C0402000C0404000C0406000C0") (310 . "408000C040A000C040C000C040E000C0600000C0602000C0604000C0606000C0608000C060A000C060C000C060E000C0800000C0802000C0804000C0806000C0808000C080A000C080C000C080E000C0A00000C0A02000C0A04000C0A06000C0A08000C0A0A000C0A0C000C0A0E000C0C00000C0C02000C0C04000C0C06000") (310 . "C0C08000C0C0A000F0FBFF00A4A0A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFF00000000000000000000000000000000000000000000000000000000FF") (310 . "FFFFFF00000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFF00000000000000FFFFFFFF00000000000000FFFF00000000000000000000FFFF00000000000000") (310 . "0000FFFF00000000000000FFFF00000000000000000000FFFF00000000000000FFFF000000000000000000FFFF00000000000000000000FFFF000000000000000000FFFF00000000000000FFFF00000000000000000000FFFF0000000000000000FFFF0000000000000000FFFF00000000000000000000FFFFFFFFFFFFFFFF") (310 . "FFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFF0000000000FF00FFFF00FF000000000000FFFF00000000000000000000FFFFFF0000000000FFFFFFFFFFFF000000000000FFFF00000000000000000000FFFFFF0000000000FFFFFFFF00FF000000000000FFFF00000000000000000000FFFFFF00000000") (310 . "00FF00FFFFFFFF000000000000FFFF00000000000000000000FFFFFF0000000000FFFFFFFF00FF000000000000FFFF00000000000000000000FFFFFF0000000000FFFFFFFFFFFF000000000000FFFF00000000000000000000FFFFFF0000000000FFFF0000FFFF000000000000FFFF00000000000000000000FFFFFF000000") (310 . "0000FFFF0000FFFF000000000000FFFF00000000000000000000FFFFFF0000000000FFFF0000FFFF000000000000FFFF00000000000000000000FFFFFF0000000000FFFF0000FFFF000000000000FFFF00000000000000000000FFFFFF0000000000FFFF0000FFFF000000000000FFFF00000000000000000000FFFFFF0000") (310 . "000000FFFF0000FFFF000000000000FFFF00000000000000000000FFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFF00000000000000000000FFFF00000000000000FF0000FF00000000000000FFFF00000000000000000000FFFF00000000000000FF0000FF00000000000000FFFF00000000000000000000FFFF0000") (310 . "0000000000FF0000FF00000000000000FFFF00000000000000000000FFFF00000000000000FF0000FF00000000000000FFFF00000000000000000000FFFF00000000000000FFFFFFFF00000000000000FFFF00000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFF") (310 . "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000000000000000000000") (102 . "{BLKREFS") (331 . <Entity name: 1c9ae40>) (102 . "}"))
_$ (assoc 331 el2)
(331 . <Entity name: 1c9ae40>)
_$
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #2 on: October 07, 2008, 11:16:23 AM »
I don't think there is an easy way, and the way that comes to mind isn't the most secure.  If you could pass the ename and a point, then you can kind of search for it, but if blocks are on top of each other, then you could come up with the wrong block.  I was thinking that you could search each block reference of the block table record, and see if the point falls within the bounding box of the block, then that will tell you which insert you want.

I don't see how a nested ename is associated with the insert, only the block definition, so that is why I'm thinking this way.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: nested ename list
« Reply #3 on: October 07, 2008, 11:39:39 AM »
Doesn't dxf 331 point to the INSERT?
Or am I missing something here?  :? <wouldn't be the first time> 8-)
Code: [Select]
Select entity to list.((-1 . <Entity name: 1c9ae40>) (0 . "INSERT") (330 .
<Entity name: 1c89010>) (5 . "A1A8") (100 . "AcDbEntity") (67 . 0) (410 .
"Model") (8 . "Duct") (100 . "AcDbBlockReference") (2 . "blk1") (10 777.399
89.6897 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44
. 0.0) (45 . 0.0) (210 0.0 0.0 1.0))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #4 on: October 07, 2008, 12:04:10 PM »
In '06 there is no 331 of the nested entity.  The code 331 is with the block record, and that will lead you to inserts, but if you select a line within the insert, and then test the dxf codes returned, there isn't a 331, at least not on my test.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #5 on: October 07, 2008, 01:34:59 PM »
Here's a quick stab that appears  to work under '08:

Code: [Select]
(defun GetGuardians ( ename / foo result )

    (defun foo ( ename / data owner )
        ;;  variable result is a lexical global
        (if (eq "BLOCK_RECORD" (cdr (assoc 0 (setq data (entget ename)))))
            (if (setq owner (cdr (assoc 331 (reverse data))))
                (foo owner)
                (setq result (cons (cdr (assoc 360 data)) result))
            )
            (if (setq result (cons ename result))
                (foo (cdr (assoc 330 data)))
            )
        )
    )

    (foo ename)

    (cdr (reverse (cdr result)))

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #6 on: October 07, 2008, 01:47:57 PM »
Here's a quick stab that appears  to work under '08:

Code: [Select]
(defun GetGuardians ( ename / foo result )

    (defun foo ( ename / data owner )
        ;;  variable result is a lexical global
        (if (eq "BLOCK_RECORD" (cdr (assoc 0 (setq data (entget ename)))))
            (if (setq owner (cdr (assoc 331 (reverse data))))
                (foo owner)
                (setq result (cons (cdr (assoc 360 data)) result))
            )
            (if (setq result (cons ename result))
                (foo (cdr (assoc 330 data)))
            )
        )
    )

    (foo ename)

    (cdr (reverse (cdr result)))

)
Try this with copying the block many times, and selecting different blocks.  It will always return the last one in the list of block references.
Quote
Command: (getguardians (car (nentsel)))

Select object: (<Entity name: 7ed2d2b0>)

Command: (getguardians (car (nentsel)))

Select object: (<Entity name: 7ed2d2b0>)

Command: (getguardians (car (nentsel)))

Select object: (<Entity name: 7ed2d2b0>)

Command: (getguardians (car (nentsel)))

Select object: (<Entity name: 7ed2d2b0>)

Quote
(-1 . <Entity name: 7ed2d098>)
(0 . "BLOCK_RECORD")
(330 . <Entity name: 7ed10c08>)
(5 . "C3")
(100 . "AcDbSymbolTableRecord")
(100 . "AcDbBlockTableRecord")
(2 . "Det-Bub")
(360 . <Entity name: 7ed2d0c0>)
(340 . <Entity name: 0>)
(102 . "{BLKREFS")
(331 . <Entity name: 7ed2d0f0>)
(331 . <Entity name: 7ed2d130>)
(331 . <Entity name: 7ed2d150>)
(331 . <Entity name: 7ed2d170>)
(331 . <Entity name: 7ed2d190>)
(331 . <Entity name: 7ed2d1b0>)
(331 . <Entity name: 7ed2d1d0>)
(331 . <Entity name: 7ed2d1f0>)
(331 . <Entity name: 7ed2d210>)
(331 . <Entity name: 7ed2d230>)
(331 . <Entity name: 7ed2d250>)
(331 . <Entity name: 7ed2d270>)
(331 . <Entity name: 7ed2d290>)
(331 . <Entity name: 7ed2d2b0>)
(102 . "}")
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #7 on: October 07, 2008, 01:57:58 PM »
Oh well. Conceptually it may contribute towards a solution. Or not. I unfortunately don't have time to play. I know you folks will pen a solid solution and I look forward to seeing it. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #8 on: October 07, 2008, 02:13:19 PM »
Oh well. Conceptually it may contribute towards a solution. Or not. I unfortunately don't have time to play. I know you folks will pen a solid solution and I look forward to seeing it. :)
I don't think I will unless an epiphanyhits me with some new knowledge.  The nested ename will only lead you to what owns it, and that is the block record.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: nested ename list
« Reply #9 on: October 07, 2008, 02:55:21 PM »
I'm scratching my head on this one so help me out.
This works in 2006 as well as 2000.
Is it not returning the correct entity?
Or have I missed the question entirely?  :-o
Code: [Select]
(defun GetInsert (ent / e1 e2 e3 el2)
  (and
  (setq e1 (entget ent))
  (setq e2 (cdr (assoc 330 e1)))
  (setq el2 (entget e2))
  (setq e3 (cdr (assoc 331 el2)))
  )
  e3
  )

(defun c:test(/ e)
  (setq e (car (nentselp)))
  (GetInsert e)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #10 on: October 07, 2008, 03:07:04 PM »
I'm scratching my head on this one so help me out.
This works in 2006 as well as 2000.
Is it not returning the correct entity?
Or have I missed the question entirely?  :-o
Code: [Select]
(defun GetInsert (ent / e1 e2 e3 el2)
  (and
  (setq e1 (entget ent))
  (setq e2 (cdr (assoc 330 e1)))
  (setq el2 (entget e2))
  (setq e3 (cdr (assoc 331 el2)))
  )
  e3
  )

(defun c:test(/ e)
  (setq e (car (nentselp)))
  (GetInsert e)
)
Same as Michaels, except that you get the first instead of the last.

Quote
Command: TEST

Select object: <Entity name: 7ed2d0e0>

Command:
Command:
TEST
Select object: <Entity name: 7ed2d0e0>

Command:
Command:
TEST
Select object: <Entity name: 7ed2d0e0>

Command:
Command:
TEST
Select object: <Entity name: 7ed2d0e0>

Command:
Command:
TEST
Select object: <Entity name: 7ed2d0e0>

Quote
(-1 . <Entity name: 7ed2d088>)
(0 . "BLOCK_RECORD")
(330 . <Entity name: 7ed10c08>)
(5 . "C1")
(100 . "AcDbSymbolTableRecord")
(100 . "AcDbBlockTableRecord")
(2 . "Det-Bub")
(360 . <Entity name: 7ed2d0b0>)
(340 . <Entity name: 0>)
(102 . "{BLKREFS")
(331 . <Entity name: 7ed2d0e0>)
(331 . <Entity name: 7ed2d100>)
(331 . <Entity name: 7ed2d120>)
(331 . <Entity name: 7ed2d140>)
(331 . <Entity name: 7ed2d160>)
(331 . <Entity name: 7ed2d180>)
(331 . <Entity name: 7ed2d1a0>)
(331 . <Entity name: 7ed2d1c0>)
(331 . <Entity name: 7ed2d1e0>)
(331 . <Entity name: 7ed2d200>)
(331 . <Entity name: 7ed2d220>)
(331 . <Entity name: 7ed2d240>)
(331 . <Entity name: 7ed2d260>)
(331 . <Entity name: 7ed2d280>)
(331 . <Entity name: 7ed2d2a0>)
(331 . <Entity name: 7ed2d2c0>)
(102 . "}")
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: nested ename list
« Reply #11 on: October 07, 2008, 03:18:01 PM »
Added some reporting to the test function.
Code: [Select]
(defun GetInsert (ent / e1 e2 e3 el2)
  (and
    (setq e1 (entget ent))
    (setq e2 (cdr (assoc 330 e1)))
    (setq el2 (entget e2))
    (setq e3 (cdr (assoc 331 el2)))
  )
  e3
)

(defun c:test (/ e)
  (setq nlist (nentselp "\nSelect nested object: "))
  (setq e (car nlist))
  (print "Nested entity : ")
  (princ e)
  (print "Insert entity : ")
  (princ (last nlist))
  (print "Start subfunction--------")
  (print "Insert entity found : ")
  (princ (GetInsert e))
  (princ)
)
This is my result in acad2006, what is yours?
Code: [Select]
Select nested object:
"Nested entity : " <Entity name: 7ef7e218>
"Insert entity : " (<Entity name: 7ef7e240>)
"Start subfunction--------"
"Insert entity found : " <Entity name: 7ef7e240>
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #12 on: October 07, 2008, 03:20:50 PM »
You will notice that the last one is correct, but all the rest are wrong.  I have inserted the object ~10 times, which will be a better test for you next time.

Quote
Command: test

Select nested object:
"Nested entity : " <Entity name: 7ed2d0a8>
"Insert entity : " (<Entity name: 7ed2d200>)
"Start subfunction--------"
"Insert entity found : " <Entity name: 7ed2d0e0>

Command:
Command:
TEST
Select nested object:
"Nested entity : " <Entity name: 7ed2d0a8>
"Insert entity : " (<Entity name: 7ed2d1e0>)
"Start subfunction--------"
"Insert entity found : " <Entity name: 7ed2d0e0>

Command:
Command:
TEST
Select nested object:
"Nested entity : " <Entity name: 7ed2d0a8>
"Insert entity : " (<Entity name: 7ed2d1c0>)
"Start subfunction--------"
"Insert entity found : " <Entity name: 7ed2d0e0>

Command:
Command:
TEST
Select nested object:
"Nested entity : " <Entity name: 7ed2d0a8>
"Insert entity : " (<Entity name: 7ed2d0e0>)
"Start subfunction--------"
"Insert entity found : " <Entity name: 7ed2d0e0>
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #13 on: October 07, 2008, 03:26:45 PM »
I forgot to ask ... what's wrong with nentselp?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: nested ename list
« Reply #14 on: October 07, 2008, 03:50:15 PM »
Hi,

My 2 cents, if I do understand the request (not deeply tested).

Code: [Select]
(defun nested-list (child / parent)
  (if (setq
parent (cdr (last (vl-remove-if-not
    '(lambda (p) (= (car p) 331))
    (entget (cdr (assoc 330 (entget child))))
  )
    )
       )
      )
    (cons child (nested-list parent))
    (list child)
  )
)
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: nested ename list
« Reply #15 on: October 07, 2008, 03:51:11 PM »
Thanks Tim, the light just went on.  8-)
When you use nentselp the entity selected returns the SAME ENAME for all inserts and
therefore all point back to the first block. Why I didn't think about the fact that the entity data for the BLOCK is
only in the BLOCK record who knows. But the insert does not contain that info therefore there in no path back to the actual
insert selected except through the nentselp function. You might be able to back into that information with a point but if
the Inserts overlapped, that would make it near imposable to locate the correct insert.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #16 on: October 07, 2008, 04:02:21 PM »
Hi,

My 2 cents, if I do understand the request (not deeply tested).

Code: [Select]
(defun nested-list (child / parent)
  (if (setq
parent (cdr (last (vl-remove-if-not
    '(lambda (p) (= (car p) 331))
    (entget (cdr (assoc 330 (entget child))))
  )
    )
       )
      )
    (cons child (nested-list parent))
    (list child)
  )
)
Same as the others gile.

Quote
Command: (nested-list (car (nentsel)))

Select object: (<Entity name: 7ed2d0a8> <Entity name: 7ed2d2c0>)


Command: (nested-list (car (nentsel)))


Select object: (<Entity name: 7ed2d0a8> <Entity name: 7ed2d2c0>)

Command: (nested-list (car (nentsel)))


Select object: (<Entity name: 7ed2d0a8> <Entity name: 7ed2d2c0>)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: nested ename list
« Reply #17 on: October 07, 2008, 04:31:16 PM »
OK, I didn't see the problem, I understand it now...
Sorry. :-(
Speaking English as a French Frog

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #18 on: October 07, 2008, 04:47:05 PM »
OK, I didn't see the problem, I understand it now...
Sorry. :-(
Not a problem.  The more people thinking on this, the more likely we are to find something, if anything is possible.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #19 on: October 07, 2008, 04:50:49 PM »
How about --

Code: [Select]
(defun GetGuardians ( ename / foo result )

    (defun foo ( ename / data owner )
        ;;  variable result is a lexical global
        (if (eq "BLOCK_RECORD" (cdr (assoc 0 (setq data (entget ename)))))
            (   (lambda ( / owner ownerdata )
                    (vl-some
                       '(lambda ( pair )
                            (and
                                (eq 331 (car pair))
                                (setq owner (cdr pair))
                                (setq ownerdata (entget owner))
                            )
                        )
                        data
                    )
                    (if ownerdata
                        (foo owner)
                        (setq result (cons (cdr (assoc 360 data)) result))
                    )
                )
            )
            (if (setq result (cons ename result))
                (foo (cdr (assoc 330 data)))
            )
        )
    )

    (foo ename)

    (cdr (reverse (cdr result)))

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #20 on: October 07, 2008, 04:53:22 PM »
Nope.

Quote
GETGUARDIANS

Command: (getguardians (car (nentsel)))

Select object: (<Entity name: 7ed2d0e0>)

Command: (getguardians (car (nentsel)))


Select object: (<Entity name: 7ed2d0e0>)


Command: (getguardians (car (nentsel)))


Select object: (<Entity name: 7ed2d0e0>)

Command: (getguardians (car (nentsel)))


Select object: (<Entity name: 7ed2d0e0>)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #21 on: October 07, 2008, 04:54:58 PM »
Well carp, it works with my sample data. :lmao:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #22 on: October 07, 2008, 04:58:03 PM »
Maybe I don't understand the challenge. I thought we were trying to replicate the nesting revealed by nentselp.

Command: (setq list1 (last (nentselp)))

Select object: (<Entity name: 7efa23a8> <Entity name: 7efa2410> <Entity name:
7efa2438> <Entity name: 7efa2460> <Entity name: 7efa2488> <Entity name:
7efa2498>)


Command: (setq list2 (getguardians (car (nentsel))))

Select object: (<Entity name: 7efa23a8> <Entity name: 7efa2410> <Entity name:
7efa2438> <Entity name: 7efa2460> <Entity name: 7efa2488> <Entity name:
7efa2498>)


Command: (mapcar 'eq list1 list2)

(T T T T T T)

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #23 on: October 07, 2008, 05:01:52 PM »
Maybe I don't understand the challenge. I thought we were trying to replicate the nesting revealed by nentselp.
We are, but with my tests nothing has worked.  All selecting the same insert, out of ~15 inserts.

Quote
Command: (nentsel)


Select object: (<Entity name: 7ed2d0a8> (-14.6347 4.44528 0.0) ((1.0 0.0 0.0)
(0.0 1.0 0.0) (0.0 0.0 1.0) (-14.1187 4.45876 0.0)) (<Entity name: 7ed2d220>))

Command: (nentselp (getpoint))
(<Entity name: 7ed2d0a8> (-14.1187 4.45876 0.0) ((1.0 0.0 0.0 -14.1187) (0.0
1.0 0.0 4.45876) (0.0 0.0 1.0 0.0) (0.0 0.0 0.0 1.0)) (<Entity name: 7ed2d220>))


Command: (getguardians (car (nentsel)))

Select object: (<Entity name: 7ed2d0e0>)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #24 on: October 07, 2008, 05:13:30 PM »
Ok, I see the problem Tim. Thanks for your patience.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #25 on: October 07, 2008, 05:18:22 PM »
Ok, I see the problem Tim. Thanks for your patience.
No problem.  You're welcome Michael.


I can't think of any way to do this, because the nested entity has nothing to do with the insert.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #26 on: October 07, 2008, 05:28:46 PM »
I'm still working on my first approach ... but just thinking outside the box, so to speak, you might be able to associate an entity with its outermost nested block(s) by analyzing their (transformed) respective bounding boxes. kludgey? Yep.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #27 on: October 07, 2008, 05:33:21 PM »
I'm still working on my first approach ... but just thinking outside the box, so to speak, you might be able to associate an entity with its outermost nested block(s) by analyzing their (transformed) respective bounding boxes. kludgey? Yep.
This will give you the bounding box of the block definition, but how can you tell where the line ( per say ) is within the drawing and not the block definition?  The entity is only know by the block definition.  Nothing changes in the nested entity codes, only on the insert, so I don't  see any association between the nested entity and the insert, but then again I hope I'm wrong.  Good luck.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #28 on: October 07, 2008, 05:39:31 PM »
I don't remember saying the bounding box analysis was limited to the block definitions. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #29 on: October 07, 2008, 05:47:21 PM »
I don't remember saying the bounding box analysis was limited to the block definitions. :)
True.  But the bounding box of the nested entity is always the same, because no matter which insert you select, the nested entity dxf code is the same.  So if you get a true result, I think it will be a false true.  But I hope you prove me wrong.  I would love to see how someone was able to find the insert from a nested entity.

Thinking about this now, I don't see how this would ever be used, or should I say that I can't see a way that it would be used without the information from nentsel(p).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #30 on: October 07, 2008, 05:59:59 PM »
You're right Tim. Without additional information over and above a nested entity name, like the absolute coordinates where it exists relative to the instance you're interested in, it is not possible to associate the (nested entity) with an arbitrary outermost block instance as only one nested entity exists per all the instances (in the block definition) - when multiple instances exist.
« Last Edit: October 07, 2008, 06:05:27 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: nested ename list
« Reply #31 on: October 07, 2008, 06:10:54 PM »
when multiple instances exist.

That's what initially got me. When Tim mentioned his ten copies of the block it finally clicked.
I agree, no way to backtrack without some point data.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: nested ename list
« Reply #32 on: October 07, 2008, 06:20:24 PM »
I've been banging my head on this.

(setq elst (nentsel "\nSelect nested object: "))
(setq nestlst (last elst))

Can nestlst be determined without using nentsel or nentselp?
IOW, a function which takes a nested ename argument and returns
the same list as nestlst.

My research on this question has not turned up a solution so far.
My attempts to code it looking at DXF codes 330 and 331 have failed.

TIA for any help.

If there are only single instances of the block definitions(s) yes.

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

Joe Burke

  • Guest
Re: nested ename list
« Reply #33 on: October 08, 2008, 12:03:22 AM »
Thanks everyone for your thoughts and replies.

I was trying to answer a question in the Autodesk customization NG so I don't have all the details. The topic is named Coordinates transformation dated 10/3

T.Willey

  • Needs a day job
  • Posts: 5251
Re: nested ename list
« Reply #34 on: October 08, 2008, 10:57:04 AM »
Thanks everyone for your thoughts and replies.

I was trying to answer a question in the Autodesk customization NG so I don't have all the details. The topic is named Coordinates transformation dated 10/3
Since they changed it, I can't even log on anymore, so I just said forget it, so I haven't been there since.  Maybe I'll go there to see what was asked.

Edit:
Here is the topic ( I think ).
[ http://discussion.autodesk.com/forums/thread.jspa?threadID=696648&tstart=0 ]

If this is the case, then you would have to see the code he is using to get the nested block information.  If he is just stepping through the block definition per insert, then it should be just a transformation matrix from the origin of the block definition, to the insertion point of the insert plus the scale and rotation of the insert.
« Last Edit: October 08, 2008, 12:00:30 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

qq2008

  • Guest
Re: nested ename list
« Reply #36 on: May 10, 2010, 09:44:33 PM »
The link:
http://discussion.autodesk.com/forums/thread.jspa?threadID=696648&tstart=0

  :-D
here is the code
Code: [Select]
;;;pickset to ename list or vla-object list
;;;Parameters:sset for the selection of sets, xflag to nil when the table into a graphic element for T, into vla object table
;;;for example: (sset->list (ssget) nil)
(defun sset->list (sset xflag / ssetlist)
 (setq ssetlist
       (vl-remove-if   'listp
              (mapcar 'cadr (ssnamex sset))
       ) ;_ end vl-remove-if
 ) ;_ end setq
 (if xflag
  (mapcar 'vlax-ename->vla-object ssetlist)
  ssetlist
 ) ;_ end if
) ;_ end defun
;;;===========================
« Last Edit: May 10, 2010, 09:51:30 PM by qq2008 »