C# How to read the block attributes in Bricscad by API?

Hi all!
I am doing some tests with Bricscad API to add and/or update Block Attributes.

AddAttribute() method works fine and attributes are added inside blocks.
The problem is when reading those attributes from block: even though attributes are saved inside blocks correctly, I can not read them through GetAttributes() method.

I noticed that GetAttributes() works fine if and only if I select Sync option in the dialog box Block Attribute Manager (as in the photo).
If I do not, GetAttributes() is not able to return saved attributes.

Unfortunately, my console application does not involve human interaction, so I can not count on Sync usage.

Is there any way to perform Sync using Bricscad API?
Alternatively, do you know any alternative way for writing and reading Blocks attributes?

NB: I would prefer not using LISP solutions.

T&R,
LemonXXX

Comments

  • avc
    avc
    edited February 2021

    If you have created a NOT constant attribute, then you must add it not only to the BTR, but to all BlockReference. There is a BlockReference.SetAttributeFromBlock method for this.