revit api use c# draw a arrow connect to textnote in floor plan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,everyone
i want to draw a arrow with textnote in floor plan
now i can use line to draw it,but it is not good enough!
this is my result:
this is my code:
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Visual;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using Autodesk.Revit.ApplicationServices;
namespace BIM_API_test1029
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
internal class TakeNote : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
MessageBox.Show("請選擇標示的點:");
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
if (uidoc == null)
{
MessageBox.Show("Error", "No document is currently open!");
return Result.Cancelled;
}
XYZ position1 = uidoc.Selection.PickPoint("pick the text origin");
XYZ position2 = uidoc.Selection.PickPoint("pick the 2nd point");
XYZ position3 = uidoc.Selection.PickPoint("pick the 3rd point ");
double width = 1.0; // <== 1.0 feet on paper
string text = "這裡有錯誤,請同學修正!";
ElementId textType = uidoc.Document.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType);
using (Transaction trans = new Transaction(uidoc.Document, "New Text Note"))
{
trans.Start();
Line line = Line.CreateBound(position1, position2);
Line line1 = Line.CreateBound(position2, position3);
DetailCurve detailCurve = doc.Create.NewDetailCurve(doc.ActiveView, line);
DetailCurve detailCurve1 = doc.Create.NewDetailCurve(doc.ActiveView, line1);
TextNote.Create(uidoc.Document, uidoc.ActiveView.Id, position3, width, text, textType);
trans.Commit();
}
return Result.Succeeded;
}
}
}