Acad 2025 rename anonymous blocks

Acad 2025 rename anonymous blocks

cameron9W9TN
Explorer Explorer
304 Views
6 Replies
Message 1 of 7

Acad 2025 rename anonymous blocks

cameron9W9TN
Explorer
Explorer

In the past I've used a couple of lisp routines to give anonymous blocks standard block names, but for whatever reason these routines are no longer working.

So, has anyone got any recommendations for working lisp routines (Acad 2025) to make anonymous blocks appear as standard blocks.  To add to the fun, the drawing that I'm currently fighting with has nested anonymous blocks!

Also, just for giggles, I've asked the Google AI to generate a routine to rename the blocks, but after a dozen attempts, I'm no further forward.

 

@cameron9W9TN  I've moved this post to the Visual LISP & AutoLISP forum to increase findability with the experts. - CGBenner

0 Likes
305 Views
6 Replies
Replies (6)
Message 2 of 7

paullimapa
Mentor
Mentor

could you share a sample dwg with these anonymous blocks and also point out which ones you want to rename?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 7

imadHabash
Mentor
Mentor

Hi,

We just need one block as test example.

Imad Habash

EESignature

0 Likes
Message 4 of 7

Sea-Haven
Mentor
Mentor

Are you talking about $AC123B67CDEF type block names ?

0 Likes
Message 5 of 7

CGBenner
Community Manager
Community Manager

@cameron9W9TN 

 

Hello, do you still need help with this question?

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

Are you talking about $AC123B67CDEF type block names ?


If you mean those starting with A$..., those are not anonymous, but just the weird Block names created by PASTEBLOCK.  [I have a routine available >here< that will force you to give a meaningful name to them, in the process of pasting.]

Anonymous Blocks come from, for example, a Block name only from a deleted Dimensions when you Purge, or a 3D Solid from Exploding a non-uniformly-scaled Block that contains one.  The Block "name" always starts with a * [with *D for deleted Dimensions, with *E for Explode-result ones, maybe some other possibilities].  INSERT and RENAME don't acknowledge their existence, so @cameron9W9TN. can you post one or more of the "couple of lisp routines" you've used, so we can at least look into how they [try to] do it?

 

Kent Cooper, AIA
Message 7 of 7

komondormrex
Mentor
Mentor

@cameron9W9TN 

check the following one

(defun c:anonymous_named (/ name suffix block_collection block_name)
  (setq name "Name"
	suffix 0
	block_collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) 
  )
  (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    '(lambda (block_definition) (cond
				  ((wcmatch (vla-get-name block_definition) "`*U*")
				   (while (not (vl-catch-all-error-p
						 (vl-catch-all-apply 'vla-item (list block_collection
										     (setq block_name (strcat name "_" (itoa (setq suffix (1+ suffix)))))
								 	       )
					         )
					       )
					  )
				   ) 
				   (princ "\n\"") (princ (vla-get-name block_definition)) (princ "\" -> \"") (princ block_name) (princ "\"")
				   (vla-put-name block_definition block_name)
				 )
				 (t)
				)
     )
  )
  (if (null block_name) (princ "\nNo anonymous block found."))
  (princ)
)

 

0 Likes