IsEqual() public static method

Judge whether the two Autodesk.Revit.DB.XYZ point are equal
public static IsEqual ( Autodesk first, Autodesk second ) : bool
first Autodesk The first Autodesk.Revit.DB.XYZ point
second Autodesk The second Autodesk.Revit.DB.XYZ point
return bool
Esempio n. 1
0
        /// <summary>
        /// Get two vectors, which indicate some edge direction which contain given point,
        /// set the given point as the start point, the other end point of the edge as end
        /// </summary>
        /// <param name="point">A point of the swept profile</param>
        /// <returns>Two vectors indicate edge direction</returns>
        protected List <Autodesk.Revit.DB.XYZ> GetRelatedVectors(Autodesk.Revit.DB.XYZ point)
        {
            // Initialize the return vector list.
            List <Autodesk.Revit.DB.XYZ> vectors = new List <Autodesk.Revit.DB.XYZ>();

            // Get all the edges which contain this point.
            // And get the vector from this point to another point
            foreach (Line line in m_edges)
            {
                if (GeomUtil.IsEqual(point, line.GetEndPoint(0)))
                {
                    Autodesk.Revit.DB.XYZ vector = GeomUtil.SubXYZ(line.GetEndPoint(1), line.GetEndPoint(0));
                    vectors.Add(vector);
                }
                if (GeomUtil.IsEqual(point, line.GetEndPoint(1)))
                {
                    Autodesk.Revit.DB.XYZ vector = GeomUtil.SubXYZ(line.GetEndPoint(0), line.GetEndPoint(1));
                    vectors.Add(vector);
                }
            }

            // only two vectors(directions) should be found
            if (2 != vectors.Count)
            {
                throw new Exception("A point on swept profile should have only two directions.");
            }

            return(vectors);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the swept profile(face) of the host object(family instance)
        /// </summary>
        /// <param name="solid">The solid reference</param>
        /// <returns>The swept profile</returns>
        private Face GetSweptProfileFace(Solid solid)
        {
            // Get a point on the swept profile from all points in solid
            Autodesk.Revit.DB.XYZ refPoint = new Autodesk.Revit.DB.XYZ(); // the point on swept profile
            foreach (Edge edge in solid.Edges)
            {
                List <XYZ> points = edge.Tessellate() as List <XYZ>; //get end points of the edge
                if (2 != points.Count)                               // make sure all edges are lines
                {
                    throw new Exception("Each edge should be a line.");
                }

                // get two points of the edge. All points in solid should be transformed first
                Autodesk.Revit.DB.XYZ first  = Transform(points[0]); // start point of edge
                Autodesk.Revit.DB.XYZ second = Transform(points[1]); // end point of edge

                // some edges should be paralleled with the driving line,
                // and the start point of that edge should be the wanted point
                Autodesk.Revit.DB.XYZ edgeVector = GeomUtil.SubXYZ(second, first);
                if (GeomUtil.IsSameDirection(edgeVector, m_drivingVector))
                {
                    refPoint = first;
                    break;
                }
                if (GeomUtil.IsOppositeDirection(edgeVector, m_drivingVector))
                {
                    refPoint = second;
                    break;
                }
            }

            // Find swept profile(face)
            Face sweptFace = null; // define the swept face

            foreach (Face face in solid.Faces)
            {
                if (null != sweptFace)
                {
                    break;
                }
                // the swept face should be perpendicular with the driving line
                if (!GeomUtil.IsVertical(face, m_drivingLine, m_transform, null))
                {
                    continue;
                }
                // use the point to get the swept face
                foreach (Autodesk.Revit.DB.XYZ point in face.Triangulate().Vertices)
                {
                    Autodesk.Revit.DB.XYZ pnt = Transform(point); // all points in solid should be transformed
                    if (GeomUtil.IsEqual(refPoint, pnt))
                    {
                        sweptFace = face;
                        break;
                    }
                }
            }

            return(sweptFace);
        }