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是文字内容。
 

猜你喜欢

转载自blog.csdn.net/weixin_40626630/article/details/84108269
今日推荐