ModelCurve represents model lines in the project. It exists in 3D space and is visible in all views.
The following pictures illustrate the four ModelCurve derived classes:
Figure 92:ModelLine and ModelArc
Figure 93: ModelEllipse and ModelNurbSpline
The key to creating a ModelCurve is to create the Geometry.Curve and SketchPlane where the Curve is located. Based on the Geometry.Curve type you input, the corresponding ModelCurve returned can be downcast to its correct type.
The following sample illustrates how to create a new model curve (ModelLine and ModelArc):
Code Region 17-2: Creating a new model curve |
// get handle to application from document Autodesk.Revit.ApplicationServices.Application application = document.Application; // 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 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; |
GeometryCurve
The GeometryCurve property is used to get or set the model curve's geometry curve. Except for ModelHermiteSpline, you can get different Geometry.Curves from the four ModelCurves;
The following code sample illustrates how to get a specific Curve from a ModelCurve.
Code Region 17-3: Getting a specific Curve from a ModelCurve |
//get the geometry modelCurve of the model modelCurve Autodesk.Revit.DB.Curve geoCurve = modelCurve.GeometryCurve; if (geoCurve is Autodesk.Revit.DB.Line) { Line geoLine = geoCurve as Line; } |
Line styles are represented by the GraphicsStyle class. All line styles for a ModelCurve are available from the GetLineStyleIds() method which returns a set of ElementIds of GraphicsStyle elements.