Revit二次开发—创建文字注释(TextNote)

关注公众号及时获取文章更新

Revit API 在2016版本及以后对创建文字注释做了改动

新版本创建方法:

using (Transaction tran = new Transaction(RevitDoc, "Creating a Text note"))
{
   XYZ origin = new XYZ(10, 10, 0);
   ElementId defaultTypeId = RevitDoc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType);

   tran.Start();
   TextNote note = TextNote.Create(RevitDoc, someView.Id, origin,  "Text Note", defaultTypeId);
   note.AddLeader(TextNoteLeaderTypes.TNLT_STRAIGHT_L);
   tran.Commit();
}
using (Transaction tran = new Transaction(RevitDoc, "Creating a Text note"))
{
   XYZ origin = new XYZ(10, 10, 0);
   double width = 3.0 / 12.0; // feet on paper

   TextNoteOptions options = new TextNoteOptions();
   options.HorizontalAlignment = HorizontalTextAlignment.Center;
   options.TypeId = RevitDoc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType);

   tran.Start();
   TextNote note = TextNote.Create(RevitDoc, someView.Id, origin, width, "Text Box Content", options);
   tran.Commit();

旧版本创建方法:

文字注释的创建方法:
通过以下方法可以创建文字注释。
①Autodesk.Revit.Creation.Document NewTextNote( View pView,XYZ origin,XYZ baseVec, XYZ upVec, double lineWidth, TextAlignFlags textAlign, string strText) 

其中,pView是文字注释所要创建在的视图,origin是其原点,baseVec和upVec决定了其水平和垂直方向,lineWidth是线宽,textAlign是文字的对齐方式,strText是文字内容。

② Autodesk.Revit.Creation.Document. NewTextNote( View pView, XYZ origin, XYZ baseVec,XYZ upVec,double lineWidth,TextAlignFlags textAlign, TextNoteLeaderTypes leaderType, TextNoteLeaderStyles leaderStyle,XYZ leaderEnd,XYZ leaderElbow,string strText)

其中,pView是文字注释所要创建在的视图,origin是其原点,baseVec和upVec决定其水平和垂直方向,lineWidth是线宽,textAlign是文字的对齐方式,leaderType是箭头的类型(直线型或弧形),leaderStyle是箭头的样式(一段直线型、一段弧线型或两段直线型),leaderEnd是箭头的端点,leaderElbow是箭头的弯曲点,strText是文字内容。
 

  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

硬核小青年

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值