This may be a little confusing, but a ‘Line’ is not the actual end result, it’s a geometry object that represents where the line will go. To actually draw the line you need to create a DetailCurve, which is the actual Detail Line.
Here’s the code that I’m talking about:
//Create the Points
double x1 = 5.0;
double y1 = 5.0;
double z = 0.0;
double x2 = 117.0;
double y2 = 115.0;
XYZ point1 = app.Application.Create.NewXYZ(x1, y1, z);
XYZ point2 = app.Application.Create.NewXYZ(x2, y2, z);
//Create line
Line line = app.Application.Create.NewLineBound(point1, point2);
DetailCurve detailCurve = doc.Create.NewDetailCurve(doc.ActiveView, line);
TaskDialog.Show("Done", "Line Created");
To run the code you’ll need to be in a transaction (or use Automatic transaction mode), and need to initialize the app and doc variables as you normally would. When you run the tool, the final result is this:
A simple line drawn on the page.
2 comments:
Thank you!
Hey thanks, it help me a lot!
Im wondering if you know how to draw a point in Revit, cause I try but i didnt find any class like "NewDetailPoint"
thanks again!
Post a Comment