Message 1 of 2
BLOCK SELECTION SET QUESTION -- Attribute Retrieval
Not applicable
12-15-2007
05:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
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