Author Topic: nested ename list  (Read 7779 times)

0 Members and 1 Guest are viewing this topic.

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.