public void CreateModelLine(XYZ p, XYZ q) { if (p.IsAlmostEqualTo(q)) { throw new ArgumentException( "Expected two different points."); } Line line = Line.CreateBound(p, q); if (null == line) { throw new Exception( "Geometry line creation failed."); } _credoc.NewModelCurve(line, NewSketchPlanePassLine(line)); }
/// <summary> /// Create the line(ModelLine) /// </summary> /// <param name="sketchId">the id of the sketch plane</param> /// <param name="startPoint">the start point of the line</param> /// <param name="endPoint">the end point of the line</param> public void CreateLine(ElementId sketchId, Autodesk.Revit.DB.XYZ startPoint, Autodesk.Revit.DB.XYZ endPoint) { try { // First get the sketch plane by the giving element id. SketchPlane workPlane = GetSketchPlaneById(sketchId); // Additional check: start point should not equal end point if (startPoint.Equals(endPoint)) { throw new ArgumentException("Two points should not be the same."); } // create geometry line Line geometryLine = Line.CreateBound(startPoint, endPoint); if (null == geometryLine) // assert the creation is successful { throw new Exception("Create the geometry line failed."); } // create the ModelLine ModelLine line = m_createDoc.NewModelCurve(geometryLine, workPlane) as ModelLine; if (null == line) // assert the creation is successful { throw new Exception("Create the ModelLine failed."); } // Add the created ModelLine into the line array m_lineArray.Append(line); // Finally refresh information map. RefreshInformationMap(); } catch (Exception ex) { throw new Exception("Can not create the ModelLine, message: " + ex.Message); } }
/// <summary> /// Create model lines representing a closed /// planar loop in the given sketch plane. /// </summary> static void DrawModelLineLoop( SketchPlane sketchPlane, XYZ[] corners) { Autodesk.Revit.Creation.Document factory = sketchPlane.Document.Create; int n = corners.GetLength(0); for (int i = 0; i < n; ++i) { int j = 0 == i ? n - 1 : i - 1; factory.NewModelCurve(Line.CreateBound( corners[j], corners[i]), sketchPlane); } }
public ModelCurve CreateModelCurve(Curve curve) { return(_credoc.NewModelCurve(curve, NewSketchPlaneContainCurve(curve))); }