Pulling the name of a Block Reference

Pulling the name of a Block Reference

Anonymous
Not applicable
954 Views
2 Replies
Message 1 of 3

Pulling the name of a Block Reference

Anonymous
Not applicable

I am trying to loop through entities in an object block reference and then pull block attributes from a specific block. I am specifically trying to pull the name of a block. Please help

0 Likes
Accepted solutions (1)
955 Views
2 Replies
Replies (2)
Message 2 of 3

grobnik
Collaborator
Collaborator
Accepted solution

Here below sample code.

 

 

 

 

For Each Object In ThisDrawing.ModelSpace
    If TypeOf Object Is AcadBlockReference Then
        If Object.Name = "NameOfBlock" then 
            ObjectIns = Object.InsertionPoint
            'ObjectIns will return a 3 points double precision array with coordinates X,Y,Z 
             If Object.HasAttributes = True Then
                ObjectAtt = Object.GetAttributes
                'ObjectAtt will return an array if block has attributes.
                ObjectAtt(0).TextString="XXXX" '<--- set first attribute value to XXX
                 MyAtt_0=ObjectAtt(0).TextString '<----retrive first attribute value, next attribute will be ObjectAtt(1).TextString, or ObjectAtt(0).TagString will retrive the Name of Attribute (LABEL).
               end if
          end if
      end if
next

 

 

 

 

Message 3 of 3

grobnik
Collaborator
Collaborator

@Anonymous Hope all above solved your issue.

0 Likes