Kairat Galiyev
Posts: 4
Registered: ‎12-07-2005
Message 1 of 1 (67 Views)

How change atrributes value programmatically?

67 Views, 0 Replies
01-24-2006 01:36 AM
Hi, everybody!

I have a problem with editing block's attributes programmaically.
Here is my code:

Database _db2 = HostApplicationServices.WorkingDatabase;
Autodesk.AutoCAD.DatabaseServices.TransactionManager tm2 = _db2.TransactionManager;
Transaction tr2 = tm2.StartTransaction();
BlockTable bt = (BlockTable)tr2.GetObject(_db2.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr2.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
foreach (ObjectId obId in btr)
DBObject dbObj = tr2.GetObject(obId, OpenMode.ForRead);
BlockReference blkRef = dbObj as BlockReference;
if (blkRef!=null)
BlockTableRecord blkDef = (BlockTableRecord)tr2.GetObject(blkRef.BlockTableRecord,OpenMode.ForRead);
foreach (ObjectId idAtt in blkDef)
Entity ent = (Entity)tr2.GetObject(idAtt, OpenMode.ForNotify);
if (ent is AttributeDefinition)
AttributeDefinition attDef = (AttributeDefinition)ent;
AttributeReference attRef = new AttributeReference();
attRef.SetAttributeFromBlock(attDef, blkRef.BlockTransform);
if (attDef.Tag == "FILE")
attRef.TextString = this.cadApp.ActiveDocument.FullName;

after executing command i have no changes with attributes
where is error?
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.