Find block(s) by 2 attributes

Find block(s) by 2 attributes

WfZC9JJ
Contributor Contributor
2,158 Views
15 Replies
Message 1 of 16

Find block(s) by 2 attributes

WfZC9JJ
Contributor
Contributor

Hi all, and thanks in advance for reading.
Is it possible to find blocks by (at least) 2 attributes?

 

For instance a block with following attributes:

attribute A = 1

attribute B = 0

 

one attribute might also work if I could pick the blockname

blockname: Blockyblock777

attribute B: 0

 

 

For a background: I'ld have dozens of blocks scattered across a drawing with different attributes assigning it to certain spaces. Sometimes I notice I have forgotten to assign one value (This I only notice after a data-extraction).

2,159 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable

I can think of a way of doing this in two steps, as you suggest. You can select all blocks by name, for example by using "quickselect" or "filter". With all blocks selected, you can use "find" to search for the attribute value.

 

0 Likes
Message 3 of 16

WfZC9JJ
Contributor
Contributor

Thanks for the reply

 

I've tried the 3 commands you've described.

But none let's me really choose an attribute with a value of "0"

 

Can you maybe elaborate?

So I've selected all the blocks from the same type. They all have a common attribute called "phase".

However one of them has a value of "0".
How do I find this block? 

0 Likes
Message 4 of 16

h_s_walker
Mentor
Mentor

You can't unless someone knows a lisp which will search a block's attribute values.

Attributes in blocks are not searchable.

I only use LT so you would need someone with full AutoCAD to answer if block attributes are searchable via lisp

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 5 of 16

john.uhden
Mentor
Mentor

Please explain more clearly.

Are you looking for block references (inserts) that contain both attribute tags A and B?

Are you looking for block references (inserts) that contain only both attribute tags A and B?

Does it matter what values they are?

When you say "A" and "B", are those the real attribute tags or might they represent some other name?

Do you want to be able to input the tag names of your choice?

Any way you answer these questions, yes we can write an AutoLisp function to find those particular inserts.  After that, what do you want to do with them?  IOW, what is the purpose of this?

John F. Uhden

0 Likes
Message 6 of 16

devitg
Advisor
Advisor

@WfZC9JJ 

 

For better understanding, and, maybe, get further help, please upload such sample.dwg

0 Likes
Message 7 of 16

Sea-Haven
Mentor
Mentor

"Sometimes I notice I have forgotten to assign one value (This I only notice after a data-extraction)."

 

Like everyone else if A & B are the 1st two attributes then easy as get-attributes can be searched in sequence do not need tagnames.

0 Likes
Message 8 of 16

Anonymous
Not applicable

@h_s_walker : I don't know if LT restrictions is the reason, but in full AutoCAD, I certainly can search (and replace) attribute values. I've done loads of it, using the "find" command, as described. Searching for empty strings, however, seems to be another matter. 

 

@WfZC9JJ : I found this thread, which seems to have part of your solution; finding empty strings in attributes. I'm afraid I'm not an experienced LISP programmer, so I can't help you any further...

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/if-attribute-value-nil/td-p/2342687

 

And another thing: For the future, if possible, adding a default value to your attributes, would give you a string to search for and make it easier to find the ones you missed. 

 

Message 9 of 16

cadffm
Consultant
Consultant

@WfZC9JJ 

Attributes are visible? The bjorns way should work.

Select your block references

set find option to search also inside attributes

Search for the value inside the selected objects

Select objects with found value.

 

(You can search for Attribute values, but you can not search for 'Att1 with value X')

 

(FIND command works the same way, so it works also in LT, with the known limitation - like unvisible attributes for example)

Sebastian

0 Likes
Message 10 of 16

h_s_walker
Mentor
Mentor

Yeah LT doesn't have the full set of bells and whistles that full AutoCAD does

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Message 11 of 16

cadffm
Consultant
Consultant

But FIND command is the same (or?)

Sebastian

0 Likes
Message 12 of 16

Sea-Haven
Mentor
Mentor
0 Likes
Message 13 of 16

TomHia
Advocate
Advocate

Hi,

To revive the question a bit - I'm pretty sure I'm trying to achieve similar thing to what the OP wanted.

Namely, among hundreds of block instances I need to find a block with certain combination of attribute values and zoom on it. Imagine doors in a huge building where each of them have attributes defining:

a) door type

b) door assigned identification number

Ident values are natural numbers starting at 1 to n for each door type. 

 

I can't just select all block instances and search for one text string value. Is there a logical operator or whatever which allows to search for a combination of attribute values using "_find" or a lisp? Order is irrelevant.

A huge QOL would've been to be able to search in XREFs but that's another story.

0 Likes
Message 14 of 16

pendean
Community Legend
Community Legend

@TomHia wrote:

Hi,

To revive the question a bit - I'm pretty sure I'm trying to achieve similar thing to what the OP wanted...


So are you a user of the LT variant of AutoCAD too like the topic you are reviving? Or...?

 

Does FIND command by chance find one or more of the attributes content you seek (especially if you use the 'zoom' ability to see it up close)?

 

Isn't this (among other posts) sort of what you are looking for

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-block-by-attribute-definition/t...

and/or

https://www.cadtutor.net/forum/topic/64787-select-blocks-by-attribute-tag/#findComment-533857

 

 

 

Message 15 of 16

ВeekeeCZ
Consultant
Consultant

@TomHia wrote:

...

I can't just select all block instances and search for one text string value. Is there a logical operator...


 

FIND the a) first, make a selection of that, then FIND b) within the active selection. That's the AND.

 

eekeeCZ_0-1740171911384.png

 

Message 16 of 16

TomHia
Advocate
Advocate

Thank you.

I think Mr. cadffm described it earlier, but the visual aid and info about using "create selection set" made it so much more clear. 

May I add for anyone searching in the future - you can partially search for the values in xrefs when you unfold the arrow:

s.PNG

However it appears that since xrefs are treated as blocks you can't narrow down the search for multiple attribute values.

Nonetheless, all of this suffices for me.

 

@pendean I'll take a look at those lisps a bit later. Thank you for listing them! I don't think OP mentioned LT anywhere, Mr. h_s_walker did.

 

I believe that modifying the search to include basic logical operators and something like values in quotation marks with escape characters wouldn't cost an arm and a leg in resources and could be a more than welcome addition to the software. Would you vote for an idea like that?

 

 

0 Likes