/// <summary> /// Create the rebar at the top of beam, according to the top rebar location /// </summary> /// <param name="location">location of rebar which need to be created</param> /// <returns>the created rebar, return null if the creation is unsuccessful</returns> private Rebar FillTopBar(TopRebarLocation location) { //get the geometry information of the rebar RebarGeometry geomInfo = m_geometry.GetTopRebar(location); RebarHookType startHookType = null; //the start hook type of the rebar RebarHookType endHookType = null; // the end hook type of the rebar RebarBarType rebarType = null; // the rebar type RebarHookOrientation startOrient = RebarHookOrientation.Right; // the start hook orient RebarHookOrientation endOrient = RebarHookOrientation.Left; // the end hook orient // decide the rebar type, hook type and hook orient according to location switch (location) { case TopRebarLocation.Start: startHookType = m_topHookType; // start hook type rebarType = m_topEndType; // rebar type startOrient = GetTopHookOrient(geomInfo, location); // start hook orient break; case TopRebarLocation.Center: rebarType = m_topCenterType; // rebar type break; case TopRebarLocation.End: endHookType = m_topHookType; // end hook type rebarType = m_topEndType; // rebar type endOrient = GetTopHookOrient(geomInfo, location); // end hook orient break; } // create the rebar return(PlaceRebars(rebarType, startHookType, endHookType, geomInfo, startOrient, endOrient)); }
/// <summary> /// Get the hook orient of the top rebar /// </summary> /// <param name="geomInfo">the rebar geometry support information</param> /// <param name="location">the location of top rebar</param> /// <returns>the hook orient of the top hook</returns> private RebarHookOrientation GetTopHookOrient(RebarGeometry geomInfo, TopRebarLocation location) { // Top center rebar doesn't need hook. if (TopRebarLocation.Center == location) { throw new Exception("Center top rebar doesn't have any hook."); } // Get the hook direction, rebar normal and rebar line Autodesk.Revit.DB.XYZ hookVec = m_geometry.GetDownDirection(); Autodesk.Revit.DB.XYZ normal = geomInfo.Normal; Line rebarLine = geomInfo.Curves[0] as Line; // get the top start hook orient if (TopRebarLocation.Start == location) { Autodesk.Revit.DB.XYZ curveVec = GeomUtil.SubXYZ(rebarLine.get_EndPoint(1), rebarLine.get_EndPoint(0)); return(GeomUtil.GetHookOrient(curveVec, normal, hookVec)); } else // get the top end hook orient { Autodesk.Revit.DB.XYZ curveVec = GeomUtil.SubXYZ(rebarLine.get_EndPoint(0), rebarLine.get_EndPoint(1)); return(GeomUtil.GetHookOrient(curveVec, normal, hookVec)); } }
/// <summary> /// Get the geometry information for top rebar /// </summary> /// <param name="location">indicate where top rebar is placed</param> /// <returns>the gotten geometry information</returns> public RebarGeometry GetTopRebar(TopRebarLocation location) { // sort the points of the swept profile XYZHeightComparer comparer = new XYZHeightComparer(); m_points.Sort(comparer); // Get the normal parameter for rebar creation List <Autodesk.Revit.DB.XYZ> directions = GetRelatedVectors(m_points[3]); directions.Sort(comparer); Autodesk.Revit.DB.XYZ normal = directions[1]; double offset = 0; //the offset from the beam surface to the rebar double startPointOffset = 0; // the offset of start point from swept profile double rebarLength = m_beamLength / 3; //the length of the rebar int rebarNumber = BeamRebarData.TopRebarNumber; //the number of the rebar // set offset and startPointOffset according to the location of rebar switch (location) { case TopRebarLocation.Start: // top start rebar offset = BeamRebarData.TopEndOffset; break; case TopRebarLocation.Center: // top center rebar offset = BeamRebarData.TopCenterOffset; startPointOffset = m_beamLength / 3 - 0.5; rebarLength = m_beamLength / 3 + 1; break; case TopRebarLocation.End: // top end rebar offset = BeamRebarData.TopEndOffset; startPointOffset = m_beamLength * 2 / 3; break; default: throw new Exception("The program should never go here."); } // Get the curve which define the shape of the top rebar curve List <Autodesk.Revit.DB.XYZ> movedPoints = OffsetPoints(offset); Autodesk.Revit.DB.XYZ startPoint = movedPoints[movedPoints.Count - 1]; // offset the start point according startPointOffset startPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, startPointOffset); // get the coordinate of endpoint Autodesk.Revit.DB.XYZ endPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, rebarLength); IList <Curve> curves = new List <Curve>(); //the profile of the top rebar curves.Add(Line.CreateBound(startPoint, endPoint)); // the spacing of the rebar double spacing = spacing = (m_beamWidth - 2 * offset) / (rebarNumber - 1); // return the rebar geometry information return(new RebarGeometry(normal, curves, rebarNumber, spacing)); }
/// <summary> /// Get the hook orient of the top rebar /// </summary> /// <param name="geomInfo">the rebar geometry support information</param> /// <param name="location">the location of top rebar</param> /// <returns>the hook orient of the top hook</returns> private RebarHookOrientation GetTopHookOrient(RebarGeometry geomInfo, TopRebarLocation location) { // Top center rebar doesn't need hook. if (TopRebarLocation.Center == location) { throw new Exception("Center top rebar doesn't have any hook."); } // Get the hook direction, rebar normal and rebar line Autodesk.Revit.DB.XYZ hookVec = m_geometry.GetDownDirection(); Autodesk.Revit.DB.XYZ normal = geomInfo.Normal; Line rebarLine = geomInfo.Curves[0] as Line; // get the top start hook orient if (TopRebarLocation.Start == location) { Autodesk.Revit.DB.XYZ curveVec = GeomUtil.SubXYZ(rebarLine.get_EndPoint(1), rebarLine.get_EndPoint(0)); return GeomUtil.GetHookOrient(curveVec, normal, hookVec); } else // get the top end hook orient { Autodesk.Revit.DB.XYZ curveVec = GeomUtil.SubXYZ(rebarLine.get_EndPoint(0), rebarLine.get_EndPoint(1)); return GeomUtil.GetHookOrient(curveVec, normal, hookVec); } }
/// <summary> /// Create the rebar at the top of beam, according to the top rebar location /// </summary> /// <param name="location">location of rebar which need to be created</param> /// <returns>the created rebar, return null if the creation is unsuccessful</returns> private Rebar FillTopBar(TopRebarLocation location) { //get the geometry information of the rebar RebarGeometry geomInfo = m_geometry.GetTopRebar(location); RebarHookType startHookType = null; //the start hook type of the rebar RebarHookType endHookType = null; // the end hook type of the rebar RebarBarType rebarType = null; // the rebar type RebarHookOrientation startOrient = RebarHookOrientation.Right;// the start hook orient RebarHookOrientation endOrient = RebarHookOrientation.Left; // the end hook orient // decide the rebar type, hook type and hook orient according to location switch (location) { case TopRebarLocation.Start: startHookType = m_topHookType; // start hook type rebarType = m_topEndType; // rebar type startOrient = GetTopHookOrient(geomInfo, location); // start hook orient break; case TopRebarLocation.Center: rebarType = m_topCenterType; // rebar type break; case TopRebarLocation.End: endHookType = m_topHookType; // end hook type rebarType = m_topEndType; // rebar type endOrient = GetTopHookOrient(geomInfo, location); // end hook orient break; } // create the rebar return PlaceRebars(rebarType, startHookType, endHookType, geomInfo, startOrient, endOrient); }
/// <summary> /// Get the geometry information for top rebar /// </summary> /// <param name="location">indicate where top rebar is placed</param> /// <returns>the gotten geometry information</returns> public RebarGeometry GetTopRebar(TopRebarLocation location) { // sort the points of the swept profile XYZHeightComparer comparer = new XYZHeightComparer(); m_points.Sort(comparer); // Get the normal parameter for rebar creation List<Autodesk.Revit.DB.XYZ > directions = GetRelatedVectors(m_points[3]); directions.Sort(comparer); Autodesk.Revit.DB.XYZ normal = directions[1]; double offset = 0; //the offset from the beam surface to the rebar double startPointOffset = 0; // the offset of start point from swept profile double rebarLength = m_beamLength / 3; //the length of the rebar int rebarNumber = BeamRebarData.TopRebarNumber; //the number of the rebar // set offset and startPointOffset according to the location of rebar switch (location) { case TopRebarLocation.Start: // top start rebar offset = BeamRebarData.TopEndOffset; break; case TopRebarLocation.Center: // top center rebar offset = BeamRebarData.TopCenterOffset; startPointOffset = m_beamLength / 3 - 0.5; rebarLength = m_beamLength / 3 + 1; break; case TopRebarLocation.End: // top end rebar offset = BeamRebarData.TopEndOffset; startPointOffset = m_beamLength * 2 / 3; break; default: throw new Exception("The program should never go here."); } // Get the curve which define the shape of the top rebar curve List<Autodesk.Revit.DB.XYZ > movedPoints = OffsetPoints(offset); Autodesk.Revit.DB.XYZ startPoint = movedPoints[movedPoints.Count - 1]; // offset the start point according startPointOffset startPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, startPointOffset); // get the coordinate of endpoint Autodesk.Revit.DB.XYZ endPoint = GeomUtil.OffsetPoint(startPoint, m_drivingVector, rebarLength); IList<Curve> curves = new List<Curve>(); //the profile of the top rebar curves.Add(Line.get_Bound(startPoint, endPoint)); // the spacing of the rebar double spacing = spacing = (m_beamWidth - 2 * offset) / (rebarNumber - 1); // return the rebar geometry information return new RebarGeometry(normal, curves, rebarNumber, spacing); }