How to find any leader that a block may be associated with.

How to find any leader that a block may be associated with.

hawstom
Advocate Advocate
899 Views
11 Replies
Message 1 of 12

How to find any leader that a block may be associated with.

hawstom
Advocate
Advocate

Given the name of a block insertion A (ename: ...D00), how would I find out that it is associated with leader B (ename: ...CB0) below?

 

I suppose I could look through all leaders and find out if one of them has a DXF group 340 reference to block A. Is there a better way?

 

Block Insertion A:

((-1 . <ENTITY NAME: 1BCCB485D00>)
  (0 . INSERT)
  (5 . 21EA8)
  (102 . {ACAD_XDICTIONARY)
  (360 . <ENTITY NAME: 1BCCB485D10>)
  (102 . })
  (102 . {ACAD_REACTORS)
  (330 . <ENTITY NAME: 1BCCB485CB0>)
  (102 . })
  (330 . <ENTITY NAME: 1BCB0C061F0>)
  (100 . ACDBENTITY)
  (67 . 0)
  (410 . MODEL)
  (8 . C-ANNO-HCNM-BUBL)
  (100 . ACDBBLOCKREFERENCE)
  (66 . 1)
  (2 . *U137)
  (10 678519.0 893354.0 0.0)
  (41 . 2.0)
  (42 . 2.0)
  (43 . 2.0)
  (50 . 0.0)
  (70 . 0)
  (71 . 0)
  (44 . 0.0)
  (45 . 0.0)
  (210 0.0 0.0 1.0)
)

 

Leader B:

((-1 . <ENTITY NAME: 1BCCB485CB0>)
  (0 . LEADER)
  (5 . 21EA3)
  (102 . {ACAD_XDICTIONARY)
  (360 . <ENTITY NAME: 1BCCB485CC0>)
  (102 . })
  (330 . <ENTITY NAME: 1BCB0C061F0>)
  (100 . ACDBENTITY)
  (67 . 0)
  (410 . MODEL)
  (8 . C-ANNO-HCNM-BUBL)
  (100 . ACDBLEADER)
  (3 . STREET)
  (71 . 1)
  (72 . 0)
  (73 . 2)
  (74 . 1)
  (75 . 0)
  (40 . 0.0)
  (41 . 0.0)
  (76 . 2)
  (10 678525.0 893343.0 0.0)
  (10 678519.0 893354.0 0.0)
  (340 . <ENTITY NAME: 1BCCB485D00>)
  (211 1.0 0.0 0.0)
  (210 0.0 0.0 1.0)
  (212 0.0 0.0 0.0)
  (213 0.0 0.0 0.0)
)
0 Likes
Accepted solutions (2)
900 Views
11 Replies
Replies (11)
Message 2 of 12

komondormrex
Mentor
Mentor

maybe you have to check every 330 group in block dxf to find target leader? or if it is the only one leader in a block get it within (102 . {ACAD_REACTORS) group?

Message 3 of 12

hawstom
Advocate
Advocate
That sounds feasible. I thought there might be a snazzy vla- or vlax- way so I could modernize (ActiveX-ize) my knowledge a bit.
Tom
0 Likes
Message 4 of 12

Kent1Cooper
Consultant
Consultant

@hawstom wrote:

Given the name of a block insertion A (ename: ...D00), how would I find out that it is associated with leader B (ename: ...CB0) below?

....


How did you get the ename of the Block insertion part, not that of the MLeader?  When I make an MLeader with the Block option in an otherwise empty drawing, there are no Block insertions in the drawing [that is, (ssget "_X") cannot find any, either by INSERT object type or by Block name] -- it's an embedded part of the Mleader object.

 

If you want to know whether a MultiLeader has a given Block name associated with it, there's a VLA property:

ContentBlockName

that you could extract from the VLA-object conversion of the Mleader.

Kent Cooper, AIA
0 Likes
Message 5 of 12

hawstom
Advocate
Advocate

@Kent1Cooper wrote:

How did you get the ename of the Block insertion part, not that of the MLeader? 


1. I am not using MLEADER because I needed block attributes exposed and I couldn't find a way to do that with MLEADER. So I am using LEADER.

 

2. In this exercise, I'm getting the block with (entsel). Given that insertion ename, I need the leader ename so I can get its start point.

 

Tom

0 Likes
Message 6 of 12

pendean
Community Legend
Community Legend

@hawstom wrote:

1. I am not using MLEADER because I needed block attributes exposed and I couldn't find a way to do that with MLEADER. So I am using LEADER.

So you just have a "loose" leader snapped to or just floating near a block? Share a sample DWG file to go with your LISP file please.

0 Likes
Message 7 of 12

hawstom
Advocate
Advocate

@pendean wrote:

have a "loose" leader snapped to or just floating near a block?

Loosely associated using the LEADER Block option. It's a separate entity. But if you move the block insertion, the leader follows. That's why the block insertion has a reactor for the leader.

 

A drawing with a few of the blocks is attached.

 

I am working on edits to this open source project: https://github.com/hawstom/cnm

In this file: https://github.com/hawstom/cnm/blob/master/Devtgh/cnm.lsp

Around line 4946.

0 Likes
Message 8 of 12

hawstom
Advocate
Advocate
The code is functional at line 5065 here: https://github.com/hawstom/cnm/blob/master/Devtgh/cnm.lsp
using the hacky group 330 and 340 checking mentioned above. I go through all the group 330's and see if any of them has a 340 reference back to the block insertion.

I would still like to do this with ActiveX instead.
0 Likes
Message 9 of 12

hawstom
Advocate
Advocate

I used this method to produce apparently functional code (based on preliminary testing) as mentioned in my reply three minutes ago

 
0 Likes
Message 10 of 12

john.uhden
Mentor
Mentor

@hawstom .

See if this helps you...

;;------------------------------------------------------------
;; Function to determine if an object (specifically of |etype)
;; is attached by standard ACAD_REACTORS to the input object:
;; added 04-12-00
;;
(defun @cv_attached? (|e |etype / |ent |react |ref)
   (setq |ent (entget |e '("*")))
   (and (setq |react (member '(102 . "{ACAD_REACTORS") |ent))
        (setq |ref (nth 1 |react))
        (= (car |ref) 330)
        (setq |ref (cdr |ref))
        (setq |ent (entget |ref))
        (= (cdr (assoc 0 |ent)) |etype)
   )
)
Ignore the pipe symbol prefixes.  They're left over from the days when local symbols weren't local at all.

John F. Uhden

Message 11 of 12

hawstom
Advocate
Advocate
Accepted solution

@john.uhden, I guess what I did here is similar except that I check all 330s to see if their entity has this entity attached.

 

 

 

(WHILE
         ;; Check all 330 groups
         (AND
           (NOT ENAME_LEADER_OLD)
           (SETQ ENAME_330 (CDR (ASSOC 330 ELIST_BLOCK_OLD)))
         )
         ;; Use the one that refers back to this block. Or move to the next one.
         (COND
           ((EQ (CDR (ASSOC 340 (ENTGET ENAME_330))) ENAME_BLOCK_OLD)(SETQ ENAME_LEADER_OLD ENAME_330))
           (T (SETQ ELIST_BLOCK_OLD (CDR (MEMBER (ASSOC 330 ELIST_BLOCK_OLD) ELIST_BLOCK_OLD)) ENAME_LEADER_OLD NIL))
         )
       )

 

 

Message 12 of 12

john.uhden
Mentor
Mentor
Accepted solution

@hawstom ,

I think I remember investigating the 340 code and for some reason ended up ignoring it.  It was so long ago.

But if your code works right then my hat's off to you.  Well done!

John F. Uhden