块属性是否可以设置为多行?
<p><font style="BACKGROUND-COLOR: #ffffff" face="Verdana">块属性是否可以设置为多行?</font> 我想做个块,块的某个属性我想让它像多行文字一样显示为多行,是否可以实现?</p><p> </p> 本帖最后由 作者 于 2010-6-25 17:22:47 编辑
public static void Test()
{
var db = HostApplicationServices.WorkingDatabase;
var doc = Application.DocumentManager.GetDocument(db);
using (var tr = db.TransactionManager.StartTransaction())
{
var bt = db.BlockTableId.GetObject(OpenMode.ForWrite) as BlockTable;
//创建一个无名块定义
var blkdef = new BlockTableRecord();
blkdef.Name = "*U";
bt.Add(blkdef);
tr.AddNewlyCreatedDBObject(blkdef, true);
//向块定义添加实体
Line line = new Line(Point3d.Origin, new Point3d(10, 0, 0));
blkdef.AppendEntity(line);
tr.AddNewlyCreatedDBObject(line, true);
//向块定义添加多行属性
AttributeDefinition attdef =
new AttributeDefinition
{
Prompt = "Input A1:",
Tag = "A1",
Height = 5,
IsMTextAttributeDefinition = true,
Position = Point3d.Origin,
};
attdef.SetDatabaseDefaults();
//在当前空间创建块引用
var btr = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord;
var blkref = new BlockReference(Point3d.Origin, blkdef.ObjectId);
btr.AppendEntity(blkref);
tr.AddNewlyCreatedDBObject(blkref, true);
//在块引用中添加属性
AttributeReference attref = new AttributeReference();
attref.SetAttributeFromBlock(attdef, blkref.BlockTransform);
attref.SetDatabaseDefaults();
blkref.AttributeCollection.AppendAttribute(attref);
tr.AddNewlyCreatedDBObject(attref, true);
//更改属性的多行文字内容
MText mt = attref.MTextAttribute;
mt.Contents = @"123\p456";
attref.MTextAttribute = mt;
attref.UpdateMTextAttribute();
tr.Commit();
}
}
<p><font face="Verdana">123</font></p> <p>学习了,原来块属性也可以用多行文本</p> 完全外行,请教一下怎样编译成可执行的文件?多谢了
页:
[1]