请高手指点,关于属性块的问题
我创建一个块,然后,创建一个属性,并添加到这个块的attributeCollection中。这时候,这个块能够显示出来,但是我定义的属性却不能。
当我选中这个块,或者把光标移动到这个块上的时候,属性就会显示了。
哪位能告诉我让属性即时显示出来该怎么做?
你的代码呢 本帖最后由 cairunbin 于 2010-11-30 13:39 编辑
lzh741206 发表于 2010-11-30 10:58 http://space.mjtd.com/static/image/common/back.gif
你的代码呢
谢谢。
代码在这里。
Database db = HostApplicationServices.WorkingDatabase;
ObjectId brId;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
BlockTableRecord newBtr = new BlockTableRecord();
bt.Add(newBtr);
trans.AddNewlyCreatedDBObject(newBtr, true);
Line horizontalGridLine = new Line(new Point3d(0, -10, 0), new Point3d(0, 10, 0));
newBtr.AppendEntity(horizontalGridLine);
trans.AddNewlyCreatedDBObject(horizontalGridLine, true);
AttributeDefinition attdef = new AttributeDefinition(new Point3d(22, 0, 0), "test only", "testAttributeDefinition", "null", ObjectId.Null);
newBtr.AppendEntity(attdef);
trans.AddNewlyCreatedDBObject(attdef, true);
BlockReference br = new BlockReference(new Point3d(30, 30 , 0), newBtr.ObjectId);
BlockTableRecord modelSpaceBtr = trans.GetObject(bt, OpenMode.ForWrite) as BlockTableRecord;
brId = modelSpaceBtr.AppendEntity(br);
trans.AddNewlyCreatedDBObject(br, true);
AttributeReference ar = new AttributeReference();
ar.SetAttributeFromBlock(attdef, br.BlockTransform);
ar.TextString = attdef.TextString;
br.AttributeCollection.AppendAttribute(ar);
ar.Visible = true;
trans.Commit();
}
br.AttributeCollection.AppendAttribute(ar);
trans.AddNewlyCreatedDBObject(ar, true);
lzh741206 发表于 2010-11-30 13:44 static/image/common/back.gif
br.AttributeCollection.AppendAttribute(ar);
trans.AddNewlyCreatedDBObject(ar, true);
非常感谢!
非常正确!
谢谢了,呵呵呵。
页:
[1]