4 Posts
0 Kudos
Registered: ‎12-07-2005
Post 1 of 1

How change atrributes value programmatically?

70 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?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!