Пример #1
0
        /// <summary>
        /// Constructor to initialize the fields.
        /// </summary>
        /// <param name="corbel">Corbel family instance</param>
        /// <param name="profile">Trapezoid profile</param>
        /// <param name="path">Extrusion Line</param>
        /// <param name="hostDepth">Corbel Host Depth</param>
        /// <param name="hostTopCorverDistance">Corbel Host cover distance</param>
        public CorbelFrame(FamilyInstance corbel, Trapezoid profile,
                           Line path, double hostDepth, double hostTopCorverDistance)
        {
            m_profile           = profile;
            m_extrusionLine     = path;
            m_corbel            = corbel;
            m_hostDepth         = hostDepth;
            m_hostCoverDistance = hostTopCorverDistance;

            // Get the cover distance of corbel from CommonCoverType.
            RebarHostData rebarHost = RebarHostData.GetRebarHostData(m_corbel);

            m_corbelCoverDistance = rebarHost.GetCommonCoverType().CoverDistance;
        }
Пример #2
0
        /// <summary>
        /// This method parses geometry information of given Corbel to construct the CorbelFrame.
        /// </summary>
        /// <param name="corbel">Given corbel family instance to parse</param>
        /// <returns>CorbelFrame object</returns>
        public static CorbelFrame ParseCorbelGeometry(FamilyInstance corbel)
        {
            // Get Corbel Host information.
            Element   corbelHost     = corbel.Host;
            Reference corbelHostFace = corbel.HostFace;

            PlanarFace hostPlane  = corbelHost.GetGeometryObjectFromReference(corbelHostFace) as PlanarFace;
            XYZ        hostNormal = GetNormalOutside(hostPlane);

            // Extract the faces in Corbel parallel with Corbel host face.
            Solid      corbelSolid      = GetElementSolid(corbel);
            PlanarFace corbelTopFace    = null;
            PlanarFace corbelBottomFace = null;

            foreach (Face face in corbelSolid.Faces)
            {
                PlanarFace planarFace = face as PlanarFace;
                XYZ        normal     = GetNormalOutside(planarFace);
                if (normal.IsAlmostEqualTo(hostNormal))
                {
                    corbelTopFace = planarFace;
                }
                else if (normal.IsAlmostEqualTo(-hostNormal))
                {
                    corbelBottomFace = planarFace;
                }
            }

            // Extract the faces in Corbel Host parallel with Corbel host face.
            Solid      hostSolid      = GetElementSolid(corbelHost);
            PlanarFace hostTopFace    = null;
            PlanarFace hostBottomFace = hostPlane;

            foreach (Face face in hostSolid.Faces)
            {
                PlanarFace planarFace = face as PlanarFace;
                XYZ        normal     = GetNormalOutside(planarFace);
                if (normal.IsAlmostEqualTo(-hostNormal))
                {
                    hostTopFace = planarFace;
                }
            }

            // Parse the side faces to find out the Trapezoid face.
            Edge       topEdge        = null;
            Edge       leftEdge       = null;
            Edge       bottomEdge     = null;
            Edge       rightEdge      = null;
            PlanarFace trapezoidFace  = null;
            int        foundEdgeIndex = -1;
            bool       foundTrapezoid = false;
            EdgeArray  bottomEdges    = corbelBottomFace.EdgeLoops.get_Item(0);

            foreach (Edge edge in bottomEdges)
            {
                bottomEdge = edge;
                foundEdgeIndex++;
                foundTrapezoid = IsTrapezoid(hostNormal, corbelBottomFace, bottomEdge,
                                             out trapezoidFace, out topEdge, out leftEdge, out rightEdge);
                if (foundTrapezoid)
                {
                    break;
                }
            }

            // Check to see if the Trapezoid faces was found.
            if (!foundTrapezoid)
            {
                // Throw if no any trapezoid face in corbel.
                throw new Exception("Didn't find the trapezoid face in corbel [Id:" + corbel.Id + "].");
            }

            Edge depthEdge = bottomEdges.get_Item((foundEdgeIndex + 1) % bottomEdges.Size);

            double hostDepth = GetDistance(hostTopFace, hostBottomFace);

            // Compute the host face cover distance.
            RebarHostData corbelHostData = RebarHostData.GetRebarHostData(corbelHost);
            // Get CoverType of the given host face
            RebarCoverType coverType = corbelHostData.GetCoverType(hostTopFace.Reference);

            // if the host face don't have a CoverType, then try to get the common CoverType.
            if (coverType == null)
            {
                coverType = corbelHostData.GetCommonCoverType();
            }
            // Get the Cover Distance
            double coverDistance = coverType.CoverDistance;

            // Construct the CorbelFrame from the given parsed trapezoid information.
            return(ConstructCorbelFrame(
                       corbel, depthEdge,
                       leftEdge, bottomEdge, rightEdge, topEdge,
                       corbel.Document, trapezoidFace,
                       hostDepth, coverDistance));
        }