Select all block follow insert field text

Select all block follow insert field text

magicdl96
Advocate Advocate
9,058 Views
23 Replies
Message 1 of 24

Select all block follow insert field text

magicdl96
Advocate
Advocate

hi all,

I have a block and I use insert field in it. I want to select all blocks with insert field as B1C3. 

I have the following code but I don't know how to choose them.

Sub SelectBlocksField()
Dim atts As Variant
Dim AcadObj As AcadObject, BlockRef As AcadBlockReference
Dim att As AcadAttributeReference
Dim ssetObj As AcadSelectionSet

For Each AcadObj In ThisDrawing.ModelSpace
    If TypeOf AcadObj Is AcadBlockReference Then
   atts = AcadObj.GetAttributes()
   For i = 0 To UBound(atts)
        Set att = atts(i)
        If InStr(1, att.TextString, "B1C3") Then
                'Select what ??
        End If
    Next
    End If
Next AcadObj
End Sub

magicdl96_0-1657190951402.png

 

0 Likes
9,059 Views
23 Replies
Replies (23)
Message 21 of 24

seabrahenrique
Advocate
Advocate

Why we have a ";" in front of your comand "SELECT?"

 

I guess this is the reason...

0 Likes
Message 22 of 24

Ed__Jobe
Mentor
Mentor

VBA just doesn't have a way to make a SelectionSet object selected on screen. I guess it's just assumed that you will only need to process the entities within code. The only thing you can do is highlight them. At least this way you could see which ones to select with the MOVE command, etc. I modified the previous code sample.

 

What I would recommend is doing something like the MOCORO command. Instead of manually running another command after selecting the blocks, add to the end if this code, the options you would like and then you can make use of ss2.

Ed


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.
How to post your code.

EESignature

0 Likes
Message 23 of 24

Ed__Jobe
Mentor
Mentor

@seabrahenrique wrote:

Why we have a ";" in front of your comand "SELECT?"

 

I guess this is the reason...


The reason is that I was mixing languages and didn't test it. oops.

Ed


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.
How to post your code.

EESignature

0 Likes
Message 24 of 24

grobnik
Collaborator
Collaborator

@magicdl96 Sorry to introduce another subject in the discussion, but I don't understand if "B1C3" it's the block name or it's an attribute name or value or something else.

Code posted by EdJobe is searching for an attribute value containing "B1C3" text or part of it, but it's supposed B1C3 it's a data contained in block attributes. Looking at object properties windows picture in the above message seems right, "B1C3" it's an attribute value of the block attribute name called "REMARKS" please let us know if it's a right assumption.

In case could you share the block as DWG ? 

Bye

0 Likes