Represent the reinforcement options of corbel. The options include bar type and bar counts which are collected from user via UI input.
        public CorbelReinforcementOptionsForm(CorbelReinforcementOptions options)
        {
            CorbelReinforcementOptions = options;

            InitializeComponent();

            Initialize();
        }
Esempio n. 2
0
        /// <summary>
        /// Add bars to reinforce the Corbel FamilyInstance with given options.
        /// The bars including:
        /// a multi-planar bar, 
        /// top straight bars, 
        /// stirrup bars, 
        /// and host straight bars.
        /// </summary>
        /// <param name="rebarOptions">Options for Rebar Creation</param>
        public void Reinforce(CorbelReinforcementOptions rebarOptions)
        {
            PlaceStraightBars(rebarOptions);

            PlaceMultiplanarRebar(rebarOptions);

            PlaceStirrupBars(rebarOptions);

            PlaceCorbelHostBars(rebarOptions);
        }
Esempio n. 3
0
        /// <summary>
        /// Add straight bars into corbel with given options. 
        /// </summary>
        /// <param name="options">Options for Rebar Creation</param>
        private void PlaceStraightBars(CorbelReinforcementOptions options)
        {
            Trapezoid profileCopy = m_profile.Clone();
            profileCopy.OffsetTop(-m_corbelCoverDistance);
            profileCopy.OffsetLeft(-m_corbelCoverDistance
                - options.MultiplanarBarType.BarDiameter
                - options.TopBarType.BarDiameter * 0.5);
            profileCopy.OffsetBottom(m_hostDepth - m_hostCoverDistance
                - options.StirrupBarType.BarDiameter
                - options.HostStraightBarType.BarDiameter);
            profileCopy.OffsetRight(-m_corbelCoverDistance);

            //m_profile.Draw(options.RevitDoc);
            //profileCopy.Draw(options.RevitDoc);

            XYZ extruDir = (m_extrusionLine.get_EndPoint(1) - m_extrusionLine.get_EndPoint(0)).Normalize();
            double offset = m_corbelCoverDistance +
                options.StirrupBarType.BarDiameter +
                options.MultiplanarBarType.BarDiameter +
                0.5 * options.TopBarType.BarDiameter;

            Line vetical = profileCopy.Vertical;
            XYZ delta = extruDir * offset;
            Curve barLine = Line.get_Bound(vetical.get_EndPoint(1) + delta, vetical.get_EndPoint(0) + delta);
            IList<Curve> barCurves = new List<Curve>();
            barCurves.Add(barLine);

            Rebar bars = Rebar.CreateFromCurves(options.RevitDoc, RebarStyle.Standard,
                options.TopBarType, null, null, m_corbel, extruDir, barCurves,
                RebarHookOrientation.Left, RebarHookOrientation.Left, true, true);

            bars.SetLayoutAsFixedNumber(options.TopBarCount+2,
                m_extrusionLine.Length - 2 * offset, true, false, false);
            ShowRebar3d(bars);
        }
Esempio n. 4
0
        /// <summary>
        /// Add stirrup bars into corbel with given options.
        /// </summary>
        /// <param name="options">Options for Rebar Creation</param>
        private void PlaceStirrupBars(CorbelReinforcementOptions options)
        {
            var filter = new FilteredElementCollector(options.RevitDoc)
                .OfClass(typeof(RebarShape)).ToElements().Cast<RebarShape>()
                .Where<RebarShape>(shape => shape.RebarStyle == RebarStyle.StirrupTie);

            RebarShape stirrupShape = null;
            foreach (RebarShape shape in filter)
            {
                if (shape.Name.Equals("T1"))
                {
                    stirrupShape = shape; break;
                }
            }

            Trapezoid profileCopy = m_profile.Clone();
            profileCopy.OffsetTop(-m_corbelCoverDistance - 0.5*options.StirrupBarType.BarDiameter);
            profileCopy.OffsetLeft(-m_corbelCoverDistance - 0.5 * options.StirrupBarType.BarDiameter);
            profileCopy.OffsetBottom(m_hostDepth - m_hostCoverDistance - 0.5 * options.StirrupBarType.BarDiameter);
            profileCopy.OffsetRight(-m_corbelCoverDistance - 0.5 * options.StirrupBarType.BarDiameter);

            XYZ extruDir = (m_extrusionLine.get_EndPoint(1) - m_extrusionLine.get_EndPoint(0)).Normalize();
            double offset = m_corbelCoverDistance + 0.5 * options.StirrupBarType.BarDiameter;

            XYZ origin = profileCopy.Vertical.get_EndPoint(0) + extruDir * offset;
            XYZ xAxis = extruDir;
            XYZ yAxis = (profileCopy.Vertical.get_EndPoint(1) - profileCopy.Vertical.get_EndPoint(0)).Normalize();

            Rebar stirrupBars = Rebar.CreateFromRebarShape(options.RevitDoc, stirrupShape,
                        options.StirrupBarType, m_corbel, origin, xAxis, yAxis);

            double xLength = m_extrusionLine.Length - 2 * offset;
            double yLength = profileCopy.Vertical.Length;

            stirrupBars.SetLayoutAsFixedNumber(options.StirrupBarCount + 1, profileCopy.Top.Length, false, false, true);
            stirrupBars.ScaleToBox(origin, xAxis * xLength, yAxis * yLength);
            ShowRebar3d(stirrupBars);

            double space = profileCopy.Top.Length / options.StirrupBarCount;
            double step = space * m_profile.Vertical.Length / (m_profile.Bottom.Length - m_profile.Top.Length);

            XYZ dirTop = (m_profile.Top.get_EndPoint(0) - m_profile.Top.get_EndPoint(1)).Normalize();
            XYZ dirVertical = yAxis;
            XYZ deltaStep = dirTop * space + dirVertical * step;

            origin = profileCopy.Top.get_EndPoint(0) + extruDir * offset;
            int count = (int)((m_profile.Vertical.Length - m_corbelCoverDistance - 0.5 * options.StirrupBarType.BarDiameter) / step);
            for (int i = 1; i <= count; i++)
            {
                origin += deltaStep;
                Rebar stirrupBars2 = Rebar.CreateFromRebarShape(options.RevitDoc, stirrupShape,
                    options.StirrupBarType, m_corbel, origin, xAxis, yAxis);

                stirrupBars2.ScaleToBox(origin, xAxis * xLength, yAxis * (yLength - i * step));
                ShowRebar3d(stirrupBars2);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Add a multi-planar bar into corbel with given options.
        /// </summary>
        /// <param name="options">Options for Rebar Creation</param>
        private void PlaceMultiplanarRebar(CorbelReinforcementOptions options)
        {
            Trapezoid profileCopy = m_profile.Clone();
            profileCopy.OffsetTop(-m_corbelCoverDistance
                - options.StirrupBarType.BarDiameter - 0.5 * options.MultiplanarBarType.BarDiameter);
            profileCopy.OffsetLeft(-m_corbelCoverDistance - 0.5 * options.MultiplanarBarType.BarDiameter);
            profileCopy.OffsetBottom(m_hostDepth - m_hostCoverDistance
                - options.HostStraightBarType.BarDiameter * 4
                - options.StirrupBarType.BarDiameter);
            profileCopy.OffsetRight(-m_corbelCoverDistance - options.StirrupBarType.BarDiameter
                - 0.5 * options.StirrupBarType.BarDiameter);

            //m_profile.Draw(options.RevitDoc);
            //profileCopy.Draw(options.RevitDoc);

            XYZ origin, vx, vy;
            profileCopy.Boundary(out origin, out vx, out vy);

            XYZ vecX = vx.Normalize();
            XYZ vecY = vy.Normalize();
            RebarShape barshape = profileCopy.ConstructMultiplanarRebarShape(options.RevitDoc,
                0.5*options.MultiplanarBarType.StirrupTieBendDiameter);
            Rebar newRebar = Rebar.CreateFromRebarShape(
                options.RevitDoc, barshape,
                options.MultiplanarBarType,
                m_corbel, origin, vecX, vecY);

            XYZ extruDir = (m_extrusionLine.get_EndPoint(1) - m_extrusionLine.get_EndPoint(0)).Normalize();
            double offset = m_corbelCoverDistance +
                options.StirrupBarType.BarDiameter +
                0.5 * options.MultiplanarBarType.BarDiameter;

            newRebar.ScaleToBoxFor3D(origin + extruDir * (m_extrusionLine.Length - offset),
                vx, vy, m_extrusionLine.Length - 2 * offset);
            ShowRebar3d(newRebar);
        }
Esempio n. 6
0
        /// <summary>
        /// Add straight bars into corbel Host to anchor corbel stirrup bars.
        /// </summary>
        /// <param name="options">Options for Rebar Creation</param>
        private void PlaceCorbelHostBars(CorbelReinforcementOptions options)
        {
            Trapezoid profileCopy = m_profile.Clone();
            profileCopy.OffsetBottom(m_hostDepth - m_hostCoverDistance
                - options.HostStraightBarType.BarDiameter * 0.5
                - options.StirrupBarType.BarDiameter);

            //profileCopy.Draw(options.RevitDoc);

            XYZ extruDir = (m_extrusionLine.get_EndPoint(1) - m_extrusionLine.get_EndPoint(0)).Normalize();
            double offset = m_corbelCoverDistance + options.StirrupBarType.BarDiameter
                + options.HostStraightBarType.BarDiameter * 0.5;
            XYZ delta = extruDir * offset;

            XYZ pt1 = profileCopy.Bottom.get_EndPoint(0) + delta;
            XYZ pt2 = profileCopy.Bottom.get_EndPoint(1) + delta;

            Curve barLine = Line.get_Bound(pt1, pt2);
            IList<Curve> barCurves = new List<Curve>();
            barCurves.Add(barLine);

            Rebar bars = Rebar.CreateFromCurves(
                options.RevitDoc, RebarStyle.Standard,
                options.HostStraightBarType, null, null, m_corbel.Host, extruDir, barCurves,
                RebarHookOrientation.Left, RebarHookOrientation.Left, true, true);

            bars.SetLayoutAsFixedNumber(2, m_extrusionLine.Length - 2 * offset, true, true, true);

            ShowRebar3d(bars);
        }
Esempio n. 7
0
        ///<summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
            ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            // A List to store the Corbels which are suitable to be reinforced.
            List<CorbelFrame> corbelsToReinforce = new List<CorbelFrame>();

            // Filter out the Corbels which can be reinforced by this sample
            // from the selected elements.
            ElementSet elems = commandData.Application.ActiveUIDocument.Selection.Elements;
            foreach (Element elem in elems)
            {
                FamilyInstance corbel = elem as FamilyInstance;

                // Make sure it's a Corbel firstly.
                if (corbel != null && IsCorbel(corbel))
                {
                    try
                    {
                        // If the Corbel is sloped, this should return a non-null object.
                        CorbelFrame frame = CorbelFrame.Parse(corbel);
                        corbelsToReinforce.Add(frame);
                    }
                    // If the Corbel is not sloped, it will throw exception.
                    catch (System.Exception ex)
                    {
                        // Collect the error message, in case there is no any suitable corbel to be reinforced,
                        // Let user know what's happened.
                        message += ex.ToString();
                    }
                }
            }

            // Check to see if there is any Corbel to be reinforced.
            if (corbelsToReinforce.Count == 0)
            {
                // If there is no suitable Corbel to be reinforced, prompt a message.
                if (string.IsNullOrEmpty(message))
                    message += "Please select sloped corbels.";

                // Return cancelled for invalid selection.
                return Result.Cancelled;
            }

            // Show a model dialog to get Rebar creation options.
            Document revitDoc = commandData.Application.ActiveUIDocument.Document;
            CorbelReinforcementOptions reinforcementOptions = new CorbelReinforcementOptions(revitDoc);
            using (CorbelReinforcementOptionsForm reinforcementOptionsForm =
                new CorbelReinforcementOptionsForm(reinforcementOptions))
            {
                if (reinforcementOptionsForm.ShowDialog() == DialogResult.Cancel)
                {
                    // Cancelled by user.
                    return Result.Cancelled;
                }
            }

            // Encapsulate operation "Reinforce Corbels" into one transaction.
            Transaction reinforceTransaction = new Transaction(revitDoc);
            try
            {
                // Start the transaction.
                reinforceTransaction.Start("Reinforce Corbels");

                // Reinforce all the corbels in list.
                foreach (CorbelFrame corbel in corbelsToReinforce)
                {
                    // Reinforce the sloped Corbel.
                    corbel.Reinforce(reinforcementOptions);
                }

                // Submit the transaction
                reinforceTransaction.Commit();
            }
            catch (System.Exception ex)
            {
                // Rollback the transaction for any exception.
                reinforceTransaction.RollBack();
                message += ex.ToString();

                // Return failed for any exception.
                return Result.Failed;
            }

            // No any error, return succeeded.
            return Result.Succeeded;
        }