Message 1 of 9

Not applicable
05-10-2012
05:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey everyone,
I'm trying to add an attribute to an entity, however it seems that the AttributeDefinition requires a Point3d and as such appear in my modelspace. I don't want this, i just wanted it to appear as an attribute with a value when i click on my entity, is there any way of making it so that i does not add into modelspace?
Cheers
Vince
{ BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); for (int i = 0; i < prSelectionResult.Value.Count; i++) { // Get the entity the user had selected Entity ent = (Entity)trans.GetObject(prSelectionResult.Value[i].ObjectId, OpenMode.ForWrite); if (ent.GetType() == typeof(BlockReference)) { // Add attribute to layer BlockReference blockRef = (BlockReference)ent; AttributeDefinition attDef = new AttributeDefinition(new Point3d(0d, 0d, 0d), "World, I'm an attribute!", "Hello", "", db.Textstyle); // Add the attribute to to the BlockTrableRecord of the blockdefinition of the selected block ObjectId btrId = blockRef.BlockTableRecord; BlockTableRecord btrBlock = (BlockTableRecord)trans.GetObject(btrId, OpenMode.ForWrite); btrBlock.AppendEntity(attDef); trans.AddNewlyCreatedDBObject(attDef, true); // Add the AttributeReference to the BlockReference AttributeReference attRef = new AttributeReference(); attRef.SetAttributeFromBlock(attDef, blockRef.BlockTransform); blockRef.AttributeCollection.AppendAttribute(attRef); trans.AddNewlyCreatedDBObject(attRef, true); } }
Solved! Go to Solution.