In Revitapi, the method of creating a model line is not in the class Modelcurve itself, which is a common confusion with APIs, and does not know where to use the interface. This can only be accumulated through experience.
The API for creating model lines is: Autodesk.Revit.Creation.NewModelCurve
Public Modelcurve Newmodelcurve (
Curve geometrycurve,
sketchplane sketchplane
)
Model Curve has 5 kinds of types, through the input corresponding Curve can get different modelcurve.
Autodesk.revit.db::modelcurve
Autodesk.revit.db::modelarc//ARC
autodesk.revit.db::modelellipse//Oval Line
Autodesk.revit.db::modelhermitespline
Autodesk.revit.db::modelline//Straight line
Autodesk.revit.db::modelnurbspline
The following example creates a straight line and an arc:
//Create a geometry line in Revit application xyz startpoint = new xyz (0, 0, 0);
XYZ endPoint = new xyz (10, 10, 0);
Line geomline = Line.createbound (StartPoint, endPoint);
Create a geometry arc in Revit application xyz end0 = new xyz (1, 0, 0);
XYZ end1 = new xyz (10, 10, 10);
XYZ Pointoncurve = new xyz (10, 0, 0);
ARC Geomarc = arc.create (end0, End1, Pointoncurve);
Create a geometry plane in Revit application XYZ origin = new xyz (0, 0, 0);
XYZ normal = new xyz (1, 1, 0);
Plane Geomplane = Plane.createbynormalandorigin (normal, origin);
Create A sketch plane in the current document Sketchplane sketch = sketchplane.create (document, Geomplane); Create a modelline element using the created geometry line and sketch plane modelline line = document.
Create.newmodelcurve (Geomline, sketch) as Modelline; Create a MODELARC element using the created geometry arc and sketch plane Modelarc arc = document.
Create.newmodelcurve (Geomarc, sketch) as Modelarc;
You can also do this through the Dynamo for Revit:
Effects in Dynamo for Revit:
Effects in Revit: