/// <summary> /// Split a circle into the upper and lower parts /// </summary> /// <param name="arc">Arc to be split</param> /// <param name="upperArc">Upper arc of the circle</param> /// <param name="lowerArc">Lower arc of the circle</param> /// <param name="bubLoc">bubble location</param> protected void TransformCircle(Arc arc, ref Arc upperArc, ref Arc lowerArc, BubbleLocation bubLoc) { Autodesk.Revit.DB.XYZ center = arc.Center; double radius = arc.Radius; Autodesk.Revit.DB.XYZ XRightPoint = new Autodesk.Revit.DB.XYZ(center.X + radius, center.Y, 0); Autodesk.Revit.DB.XYZ XLeftPoint = new Autodesk.Revit.DB.XYZ(center.X - radius, center.Y, 0); Autodesk.Revit.DB.XYZ YUpperPoint = new Autodesk.Revit.DB.XYZ(center.X, center.Y + radius, 0); Autodesk.Revit.DB.XYZ YLowerPoint = new Autodesk.Revit.DB.XYZ(center.X, center.Y - radius, 0); if (bubLoc == BubbleLocation.StartPoint) { upperArc = Arc.Create(XRightPoint, XLeftPoint, YUpperPoint); lowerArc = Arc.Create(XLeftPoint, XRightPoint, YLowerPoint); } else { upperArc = Arc.Create(XLeftPoint, XRightPoint, YUpperPoint); lowerArc = Arc.Create(XRightPoint, XLeftPoint, YLowerPoint); } }
/// <summary> /// Get the arc to create grid according to the specified bubble location /// </summary> /// <param name="origin">Arc grid's origin</param> /// <param name="radius">Arc grid's radius</param> /// <param name="startDegree">Arc grid's start degree</param> /// <param name="endDegree">Arc grid's end degree</param> /// <param name="bubLoc">Arc grid's Bubble location</param> /// <returns>The expected arc to create grid</returns> protected Arc TransformArc(Autodesk.Revit.DB.XYZ origin, double radius, double startDegree, double endDegree, BubbleLocation bubLoc) { Arc arcToCreate; // Get start point and end point of the arc and the middle point on the arc Autodesk.Revit.DB.XYZ startPoint = new Autodesk.Revit.DB.XYZ(origin.X + radius * Math.Cos(startDegree), origin.Y + radius * Math.Sin(startDegree), origin.Z); Autodesk.Revit.DB.XYZ midPoint = new Autodesk.Revit.DB.XYZ(origin.X + radius * Math.Cos((startDegree + endDegree) / 2), origin.Y + radius * Math.Sin((startDegree + endDegree) / 2), origin.Z); Autodesk.Revit.DB.XYZ endPoint = new Autodesk.Revit.DB.XYZ(origin.X + radius * Math.Cos(endDegree), origin.Y + radius * Math.Sin(endDegree), origin.Z); if (bubLoc == BubbleLocation.StartPoint) { arcToCreate = Arc.Create(startPoint, endPoint, midPoint); } else { arcToCreate = Arc.Create(endPoint, startPoint, midPoint); } return(arcToCreate); }
/// <summary> /// Create an arc grid with its origin, radius, start degree, end degree and bubble location /// </summary> /// <param name="origin">Arc grid's origin</param> /// <param name="radius">Arc grid's radius</param> /// <param name="startDegree">Arc grid's start degree</param> /// <param name="endDegree">Arc grid's end degree</param> /// <param name="bubLoc">Arc grid's Bubble location</param> /// <returns>The newly created grid</returns> private Grid CreateArcGrid(XYZ origin, double radius, double startDegree, double endDegree, BubbleLocation bubLoc) { // Get start point and end point of the arc and the middle point on the arc XYZ startPoint = m_doc.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos(startDegree), origin.Y + radius * Math.Sin(startDegree), origin.Z); XYZ midPoint = m_doc.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos((startDegree + endDegree) / 2), origin.Y + radius * Math.Sin((startDegree + endDegree) / 2), origin.Z); XYZ endPoint = m_doc.Document.Application.Create.NewXYZ(origin.X + radius * Math.Cos(endDegree), origin.Y + radius * Math.Sin(endDegree), origin.Z); Arc arc; if (bubLoc == BubbleLocation.StartPoint) { arc = Arc.Create(startPoint, endPoint, midPoint); } else { arc = Arc.Create(endPoint, startPoint, midPoint); } return(Grid.Create(m_doc.Document, arc)); }
/// <summary> /// Get the line to create grid according to the specified bubble location /// </summary> /// <param name="line">The original selected line</param> /// <param name="bubLoc">bubble location</param> /// <returns>The line to create grid</returns> protected Line TransformLine(Line line, BubbleLocation bubLoc) { Line lineToCreate; // Create grid according to the bubble location if (bubLoc == BubbleLocation.StartPoint) { lineToCreate = line; } else { Autodesk.Revit.DB.XYZ startPoint = line.get_EndPoint(1); Autodesk.Revit.DB.XYZ endPoint = line.get_EndPoint(0); lineToCreate = NewLine(startPoint, endPoint); } return lineToCreate; }
/// <summary> /// Split a circle into the upper and lower parts /// </summary> /// <param name="arc">Arc to be split</param> /// <param name="upperArc">Upper arc of the circle</param> /// <param name="lowerArc">Lower arc of the circle</param> /// <param name="bubLoc">bubble location</param> protected void TransformCircle(Arc arc, ref Arc upperArc, ref Arc lowerArc, BubbleLocation bubLoc) { Autodesk.Revit.DB.XYZ center = arc.Center; double radius = arc.Radius; Autodesk.Revit.DB.XYZ XRightPoint = new Autodesk.Revit.DB.XYZ (center.X + radius, center.Y, 0); Autodesk.Revit.DB.XYZ XLeftPoint = new Autodesk.Revit.DB.XYZ (center.X - radius, center.Y, 0); Autodesk.Revit.DB.XYZ YUpperPoint = new Autodesk.Revit.DB.XYZ (center.X, center.Y + radius, 0); Autodesk.Revit.DB.XYZ YLowerPoint = new Autodesk.Revit.DB.XYZ (center.X, center.Y - radius, 0); if (bubLoc == BubbleLocation.StartPoint) { upperArc = m_appCreator.NewArc(XRightPoint, XLeftPoint, YUpperPoint); lowerArc = m_appCreator.NewArc(XLeftPoint, XRightPoint, YLowerPoint); } else { upperArc = m_appCreator.NewArc(XLeftPoint, XRightPoint, YUpperPoint); lowerArc = m_appCreator.NewArc(XRightPoint, XLeftPoint, YLowerPoint); } }
/// <summary> /// Get the arc to create grid according to the specified bubble location /// </summary> /// <param name="origin">Arc grid's origin</param> /// <param name="radius">Arc grid's radius</param> /// <param name="startDegree">Arc grid's start degree</param> /// <param name="endDegree">Arc grid's end degree</param> /// <param name="bubLoc">Arc grid's Bubble location</param> /// <returns>The expected arc to create grid</returns> protected Arc TransformArc(Autodesk.Revit.DB.XYZ origin, double radius, double startDegree, double endDegree, BubbleLocation bubLoc) { Arc arcToCreate; // Get start point and end point of the arc and the middle point on the arc Autodesk.Revit.DB.XYZ startPoint = new Autodesk.Revit.DB.XYZ (origin.X + radius * Math.Cos(startDegree), origin.Y + radius * Math.Sin(startDegree), origin.Z); Autodesk.Revit.DB.XYZ midPoint = new Autodesk.Revit.DB.XYZ (origin.X + radius * Math.Cos((startDegree + endDegree) / 2), origin.Y + radius * Math.Sin((startDegree + endDegree) / 2), origin.Z); Autodesk.Revit.DB.XYZ endPoint = new Autodesk.Revit.DB.XYZ (origin.X + radius * Math.Cos(endDegree), origin.Y + radius * Math.Sin(endDegree), origin.Z); if (bubLoc == BubbleLocation.StartPoint) { arcToCreate = m_appCreator.NewArc(startPoint, endPoint, midPoint); } else { arcToCreate = m_appCreator.NewArc(endPoint, startPoint, midPoint); } return arcToCreate; }
/// <summary> /// Get the arc to create grid according to the specified bubble location /// </summary> /// <param name="arc">The original selected line</param> /// <param name="bubLoc">bubble location</param> /// <returns>The arc to create grid</returns> protected Arc TransformArc(Arc arc, BubbleLocation bubLoc) { Arc arcToCreate; if (bubLoc == BubbleLocation.StartPoint) { arcToCreate = arc; } else { // Get start point, end point of the arc and the middle point on it Autodesk.Revit.DB.XYZ startPoint = arc.get_EndPoint(0); Autodesk.Revit.DB.XYZ endPoint = arc.get_EndPoint(1); bool clockwise = (arc.Normal.Z == -1); // Get start angel and end angel of arc double startDegree = arc.get_EndParameter(0); double endDegree = arc.get_EndParameter(1); // Handle the case that the arc is clockwise if (clockwise && startDegree > 0 && endDegree > 0) { startDegree = 2 * Values.PI - startDegree; endDegree = 2 * Values.PI - endDegree; } else if (clockwise && startDegree < 0) { double temp = endDegree; endDegree = -1 * startDegree; startDegree = -1 * temp; } double sumDegree = (startDegree + endDegree) / 2; while (sumDegree > 2 * Values.PI) { sumDegree -= 2 * Values.PI; } while (sumDegree < -2 * Values.PI) { sumDegree += 2 * Values.PI; } Autodesk.Revit.DB.XYZ midPoint = new Autodesk.Revit.DB.XYZ (arc.Center.X + arc.Radius * Math.Cos(sumDegree), arc.Center.Y + arc.Radius * Math.Sin(sumDegree), 0); arcToCreate = m_appCreator.NewArc(endPoint, startPoint, midPoint); } return arcToCreate; }