-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get Attributes #304
Comments
Hi @Gora1000 To get the attributes for an instance of a block you have to get all the Inserts in the model, like: CadDocument doc = DwgReader.Read(path);
foreach (Insert insert in doc.Entities.OfType<Insert>())
{
//Do something with: insert.Attributes;
} Let me know if this helps. |
Hi DomCr, thaks for your answer. With doc.Entities you get all blocks of type insert in the model space, but not from layout. For exsample I added a test.dwg to my answer. I you open the file, you will find 3 Blocks in the Model space and in each layout the same one. In test.dwg two Layouts. If you use you will get only three blocks from model space, but i need the Attributes from the Block in Layout. If it should work, and i can change attribute values on the block in a layout. It is possible to save the changes at the same dwg file? |
Each Layout has it's own Block associated to it, which is the one that contains all the entities, you can iterate throw all layouts using: foreach (Objects.Layout layout in doc.Layouts)
{
BlockRecord block = layout.AssociatedBlock;
foreach (Insert insert in block.Entities.OfType<Insert>())
{
//Do something with: insert.Attributes
}
} This way you will get all the block instances (Insert) in the Layout that you want. You can save the file using Let me know if this helps. |
Hello
how is the best way to get the attributes from a Block in a Layout?
The text was updated successfully, but these errors were encountered: