BLOCK SELECTION SET QUESTION -- Attribute Retrieval

BLOCK SELECTION SET QUESTION -- Attribute Retrieval

Anonymous
Not applicable
342 Views
1 Reply
Message 1 of 2

BLOCK SELECTION SET QUESTION -- Attribute Retrieval

Anonymous
Not applicable
Hi
I am trying to accomplish something, I think is relatively simple. I would like to select all the blocks in a DWG file and loop through its attributes where I will load some information into them. I had something that was working, but for some reason it is not "universal" enough as some drawings that ran through it completely ignore the blocks. Therefore, I think I am definitely doing something wrong.

Here is what I have:

gbl_app.Documents.Open(strfile, 0, 0);
AcadDocument doc = gbl_app.ActiveDocument;

foreach (AcadBlock blk in doc.Blocks)
{
try
{
foreach (AcadBlockReference blkref in blk)
{
if (blkref.HasAttributes == true)
{
Object[] OBJECT_ATT = (Object[])blkref.GetAttributes();

foreach (Object objAttr in OBJECT_ATT)
{
AcadAttributeReference attref = (AcadAttributeReference)objAttr;

attref.TextString = "DATA"

}
}
}
}
}
}

Can anyone give me an example how I can use a Selection Set to just select all the blocks on a drawing so I can loop through their selection set to read/modify block attributes???

Thanks
0 Likes
343 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Oh yes, some more information. I am developing my application using C# .NET through the AutoCAD COM interface. Thanks!
0 Likes