/// <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.GetEndPoint(1), rebarLine.GetEndPoint(0));
                return(GeomUtil.GetHookOrient(curveVec, normal, hookVec));
            }
            else // get the top end hook orient
            {
                Autodesk.Revit.DB.XYZ curveVec = GeomUtil.SubXYZ(rebarLine.GetEndPoint(0), rebarLine.GetEndPoint(1));
                return(GeomUtil.GetHookOrient(curveVec, normal, hookVec));
            }
        }
        /// <summary>
        /// Create the transverse rebars, according to the location of transverse rebars
        /// </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>
        public Rebar FillTransverseBar(TransverseRebarLocation location)
        {
            // Get the geometry information which support rebar creation
            RebarGeometry geomInfo = new RebarGeometry();

            switch (location)
            {
            case TransverseRebarLocation.Start: // start transverse rebar
            case TransverseRebarLocation.End:   // end transverse rebar
                geomInfo = m_geometry.GetTransverseRebar(location, m_transverseEndSpacing);
                break;

            case TransverseRebarLocation.Center:// center transverse rebar
                geomInfo = m_geometry.GetTransverseRebar(location, m_transverseCenterSpacing);
                break;
            }

            RebarHookOrientation startHook = RebarHookOrientation.Right;
            RebarHookOrientation endHook   = RebarHookOrientation.Left;

            if (!GeomUtil.IsInRightDir(geomInfo.Normal))
            {
                startHook = RebarHookOrientation.Left;
                endHook   = RebarHookOrientation.Right;
            }

            // create the rebar
            return(PlaceRebars(m_transverseType, m_transverseHookType, m_transverseHookType,
                               geomInfo, startHook, endHook));
        }
        /// <summary>
        /// Create the transverse rebars, according to the transverse 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>
        public Rebar FillTransverseBar(TransverseRebarLocation location)
        {
            // Get the geometry information which support rebar creation
            RebarGeometry geomInfo = new RebarGeometry();
            RebarBarType  barType  = null;

            switch (location)
            {
            case TransverseRebarLocation.Start: // start transverse rebar
            case TransverseRebarLocation.End:   // end transverse rebar
                geomInfo = m_geometry.GetTransverseRebar(location, m_transverseEndSpacing);
                barType  = m_transverseEndType;
                break;

            case TransverseRebarLocation.Center:// center transverse rebar
                geomInfo = m_geometry.GetTransverseRebar(location, m_transverseCenterSpacing);
                barType  = m_transverseCenterType;
                break;

            default:
                break;
            }

            // create the rebar
            return(PlaceRebars(barType, m_transverseHookType, m_transverseHookType,
                               geomInfo, RebarHookOrientation.Right, RebarHookOrientation.Left));
        }
        /// <summary>
        /// Create the rebar at the bottom of beam
        /// </summary>
        /// <returns>true if the creation is successful, otherwise false</returns>
        public bool FillBottomBars()
        {
            // get the geometry information of the bottom rebar
            RebarGeometry geomInfo = m_geometry.GetBottomRebar();

            // create the rebar
            Rebar rebar = PlaceRebars(m_bottomType, null, null, geomInfo,
                                      RebarHookOrientation.Left, RebarHookOrientation.Left);

            return(null != rebar);
        }
Exemplo n.º 6
0
        /// <summary>
        /// A wrap fuction which used to create the reinforcement.
        /// </summary>
        /// <param name="rebarType">The element of RebarBarType</param>
        /// <param name="startHook">The element of start RebarHookType</param>
        /// <param name="endHook">The element of end RebarHookType</param>
        /// <param name="geomInfo">The goemetry information of the rebar</param>
        /// <param name="startOrient">An Integer defines the orientation of the start hook</param>
        /// <param name="endOrient">An Integer defines the orientation of the end hook</param>
        /// <returns></returns>
        protected Rebar PlaceRebars(RebarBarType rebarType, RebarHookType startHook,
                                    RebarHookType endHook, RebarGeometry geomInfo,
                                    RebarHookOrientation startOrient, RebarHookOrientation endOrient)
        {
            Autodesk.Revit.DB.XYZ normal = geomInfo.Normal; // the direction of rebar distribution
            IList <Curve>         curves = geomInfo.Curves; // the shape of the rebar curves

            // Invoke the NewRebar() method to create rebar
            Rebar createdRebar = Rebar.CreateFromCurves(m_revitDoc, Autodesk.Revit.DB.Structure.RebarStyle.Standard, rebarType, startHook, endHook,
                                                        m_hostObject, normal, curves,
                                                        startOrient, endOrient, false, true);

            if (null == createdRebar)   // Assert the creation is successful
            {
                return(null);
            }

            // Change the rebar number and spacing properties to the user wanted
            SetRebarSpaceAndNumber(createdRebar, geomInfo.RebarNumber, geomInfo.RebarSpacing);
            return(createdRebar);
        }
        /// <summary>
        /// Create the vertical rebar according the 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>
        public Rebar FillVerticalBar(VerticalRebarLocation location)
        {
            //calculate the rebar number in different location
            int rebarNubmer = m_verticalRebarNumber / 4;

            switch (location)
            {
            case VerticalRebarLocation.East:    // the east vertical rebar
                if (0 < m_verticalRebarNumber % 4)
                {
                    rebarNubmer++;
                }
                break;

            case VerticalRebarLocation.North:   // the north vertical rebar
                if (2 < m_verticalRebarNumber % 4)
                {
                    rebarNubmer++;
                }
                break;

            case VerticalRebarLocation.West:    // the west vertical rebar
                if (1 < m_verticalRebarNumber % 4)
                {
                    rebarNubmer++;
                }
                break;

            case VerticalRebarLocation.South:   // the south vertical rebar
                break;
            }

            // get the geometry information for rebar creation
            RebarGeometry geomInfo = m_geometry.GetVerticalRebar(location, rebarNubmer);

            // create the rebar
            return(PlaceRebars(m_verticalType, null, null, geomInfo,
                               RebarHookOrientation.Left, RebarHookOrientation.Left));
        }