Lisp update specific block attribute in drawing

Lisp update specific block attribute in drawing

Anonymous
Not applicable
990 Views
6 Replies
Message 1 of 7

Lisp update specific block attribute in drawing

Anonymous
Not applicable

Hello,

 

I have created a list of blocks for my drawing and I have created a draw with my blocks and connected them with lines/polylines. Now I need to make a lisp program to update specific blocks in the draw and add some more attributes to them. So the question is how do I loop in all blocks inside the draw and update a specific attribute to them? I have found how to loop on the blocks but these were the blocks of my toolbar while I need to find their entities inside the draw and there to update their attributes.

 

Thanks

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

ВeekeeCZ
Consultant
Consultant

A list of what? block names, enames, vla-objects?? 

 

Since you have a list already, so just use...

 

(foreach b lst (command "_.attsync" "_n/s" b...))

 


0 Likes
Message 3 of 7

Anonymous
Not applicable

I have a list of the 20 block I have on my file. When I add them multiple times inside the drawing I need this larger list of them inside the drawing and there to update one attribute. 

 

With this:

 

(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for blk (vla-get-blocks adoc)

 

I get the list of block. But I don't need this list but the list of blocked that have been added to the drawing. If I understand correctly I need the vla-objects but from a specific block.

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

It's a bit complicated for me to follow you. Try to use terms like block-definition and block-reference. Do you understand the difference between them? That's essential.

 

Also if you change your block (-definition), then use the ATTSYNC command (in AutoCAD) to update selected blocks(-references), will this work for you as you need?

0 Likes
Message 5 of 7

Anonymous
Not applicable

Let me describe it differently. I have a drawing consisting of blocks that are connected with lines & poly-lines. In the attached screenshot I have marked these blocks with a black arrow. So in this drawing with this command I can get the 3 line objects:

 

(setq linespoly (ssget "_X" '((0 . "Line,Lwpolyline"))))

 

I would like to do something similar for the instances of blocks of this drawing which are about 13. These 13 elements have been inserted there by selecting 2 specific blocks from the block list on my toolbar.

 

Χωρίς τίτλο.png

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant

Use terms like block-definition and block-reference. Do you understand the difference between them? That's essential.

 

Also if you change your block (-definition), then use the ATTSYNC command (in AutoCAD) to update selected blocks(-references), will this work for you as you need?

0 Likes
Message 7 of 7

Sea-Haven
Mentor
Mentor

You can multiple filter ssget is that what you mean ?

 

(ssget (List (cons 0 "INSERT")(cons 2 blkname)))

0 Likes