revit api use c# draw a arrow connect to textnote in floor plan

revit api use c# draw a arrow connect to textnote in floor plan

m11105508
Contributor Contributor
368 Views
2 Replies
Message 1 of 3

revit api use c# draw a arrow connect to textnote in floor plan

m11105508
Contributor
Contributor

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:

m11105508_0-1671202550279.png

 

 

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;
}
}
}

369 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

Do it in the user interface to suit your needs.

  

Then, reproduce the same result using the API.

  

The API will not do anything more than the UI does.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 3

m11105508
Contributor
Contributor

ok,thank you 

ouob