/// <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(int 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 = m_createApp.NewLine(startPoint, endPoint, true); 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 the arc(ModelArc) /// </summary> /// <param name="sketchId">the id of the sketch plane</param> /// <param name="startPoint">the start point of the arc</param> /// <param name="endPoint">the end point of the arc</param> /// <param name="thirdPoint">the third point which is on the arc</param> public void CreateArc(int sketchId, Autodesk.Revit.DB.XYZ startPoint, Autodesk.Revit.DB.XYZ endPoint, Autodesk.Revit.DB.XYZ thirdPoint) { try { // First get the sketch plane by the giving element id. SketchPlane workPlane = GetSketchPlaneById(sketchId); // Additional check: the start, end and third point should not be the same if (startPoint.Equals(endPoint) || startPoint.Equals(thirdPoint) || endPoint.Equals(thirdPoint)) { throw new ArgumentException("Three points should not be the same."); } // create the geometry arc Arc geometryArc = m_createApp.NewArc(startPoint, endPoint, thirdPoint); if (null == geometryArc) // assert the creation is successful { throw new Exception("Create the geometry arc failed."); } // create the ModelArc ModelArc arc = m_createDoc.NewModelCurve(geometryArc, workPlane) as ModelArc; if (null == arc) // assert the creation is successful { throw new Exception("Create the ModelArc failed."); } // Add the created ModelArc into the arc array m_arcArray.Append(arc); // Finally refresh information map. RefreshInformationMap(); } catch (Exception ex) { throw new Exception("Can not create the ModelArc, message: " + ex.Message); } }