Picking a block to save it's name for later in a routine

Picking a block to save it's name for later in a routine

Anonymous
Not applicable
916 Views
2 Replies
Message 1 of 3

Picking a block to save it's name for later in a routine

Anonymous
Not applicable

I know this is a simple thing to do, but I'm a hack, so I'm putting it out there:

 

I want to be able to select a block in a drawing and set it's name as a setq value, so I can use that name later in the same routine in an "insert" string.

 

What's the best way to achieve this??

 

Thanks.

0 Likes
Accepted solutions (1)
917 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

This should cover either an ordinary or a dynamic Block:

 

(setq blkname

  (vla-get-effectivename

    (vlax-ename->vla-object (car (entsel "\nSelect Block: ")))

  )

)

 

If they will never be dynamic  Blocks, it can be slightly simpler:

 

(setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block: "))))))

Kent Cooper, AIA
Message 3 of 3

Anonymous
Not applicable

Thanks Kent! Greatly appreciated!

 

Doug

0 Likes