.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How change atrributes value programmatically?

0 REPLIES 0
Reply
Message 1 of 1
kairat.galiyev
167 Views, 0 Replies

How change atrributes value programmatically?

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);
attRef.SetPropertiesFrom(attDef);
WinForms.MessageBox.Show(attRef.Tag);
if (attDef.Tag == "FILE")
{
attRef.TextString = this.cadApp.ActiveDocument.FullName;
WinForms.MessageBox.ShowattRef.TextString);
}
}
}
}
}
tr2.Commit();

after executing command i have no changes with attributes
where is error?
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost