Get information into blockreference by using c.#

Get information into blockreference by using c.#

anhtrung
Advocate Advocate
664 Views
3 Replies
Message 1 of 4

Get information into blockreference by using c.#

anhtrung
Advocate
Advocate

Hi anybody,

 

I have a question that is how to do get information into blockreference.  Can see attached image below and have a markup red color on properties of it. Help me please. 

I'm using C.#

 

Thanks.

 

Capture.PNG

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

_gile
Consultant
Consultant
Accepted solution

Hi,

 

These are called attribute references (AttributeReference).

They are contained in the AttributeCollection of the block reference.

You can use some function like the following to get the attribute values.

 

Dictionary<string, string> GetAttributeValues(BlockReference br, Transaction tr) =>
    br.AttributeCollection
        .Cast<ObjectId>()
        .Select(id => (AttributeReference)tr.GetObject(id, OpenMode.ForRead))
        .ToDictionary(att => att.Tag, att => att.TextString)

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 4

ActivistInvestor
Mentor
Mentor

In the image you posted, the values you circled in red don't appear to be block attributes.

 

Can you tell more about these values, and where they come from?

 


@anhtrungwrote:

Hi anybody,

 

I have a question that is how to do get information into blockreference.  Can see attached image below and have a markup red color on properties of it. Help me please. 

I'm using C.#

 

Thanks.

 

Capture.PNG


 

0 Likes
Message 4 of 4

anhtrung
Advocate
Advocate

@_gile Thanks, that is the needed.

0 Likes