Change all block definitions

Change all block definitions

de_king
Participant Participant
477 Views
5 Replies
Message 1 of 6

Change all block definitions

de_king
Participant
Participant

Hi

I want to change their definition in my DWG for all blocks in the dwg.

-everything to layer 0 and by layer in the definition

-Also the attributes of every block in the definitioni  i want to layer 0 and by layer

thx

 

0 Likes
Accepted solutions (2)
478 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

See >this<, and modify it as in Messages 17 & 18 there, and also look at other routines in that Topic [if you prefer mine, it can easily be modified to do all Blocks instead of just selected ones].  You will probably find other such routines with a little Searching.

Kent Cooper, AIA
Message 3 of 6

komondormrex
Mentor
Mentor
Accepted solution

hey,

check this

 

 

(defun c:all_blocks_0_bylayer nil
	(vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
		'(lambda (block_definition)
		 	(if (and
			      	(zerop (vlax-get block_definition 'islayout))
			      	(snvalid (vla-get-name block_definition)) 
			    )
			   	(vlax-map-collection block_definition
					'(lambda (object)
					 	(progn
							(vla-put-layer object "0")
						  	(vla-put-color object 256)
						)
					 )
			  	)
			 )
		)
	)
  	(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport) 
  	(princ)
)

 

 

Message 4 of 6

de_king
Participant
Participant

thanks already

solution partially works

only the blocks may go to layer 0 and color by layer...everything has been changed

0 Likes
Message 5 of 6

komondormrex
Mentor
Mentor
Accepted solution

sure. layouts. check update.

0 Likes
Message 6 of 6

de_king
Participant
Participant

it works for most of my blocks

But i have blocks where i have to do an attsync first

Strange because attsync is only for the attributes i thaught?

There are polyline changing from color after using attsync, never seen this

 

( I have used dynamic blocks also)

0 Likes