public static dynamic GetTSObject(RebarGeometry dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <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);
        }
Example #4
0
        /// <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);
             }
        }
Example #5
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;
        }