The helper class which give some operation about point and vector. The point and vector are both presented by Autodesk.Revit.DB.XYZ structure.
Пример #1
0
        /// <summary>
        /// Generate a Transform instance which as Transform property of BoundingBoxXYZ,
        /// when the user select a floor, this method will be called
        /// </summary>
        /// <returns>the reference of Transform, return null if it can't be generated</returns>
        Transform GenerateFloorTransform()
        {
            Transform transform = null;
            Floor     floor     = m_currentComponent as Floor;

            // First get the Analytical Model lines
            AnalyticalModel model = floor.GetAnalyticalModel();

            if (null == model)
            {
                m_errorInformation = "Please select a structural floor.";
                return(transform);
            }

            CurveArray    curves    = m_project.Document.Application.Create.NewCurveArray();
            IList <Curve> curveList = model.GetCurves(AnalyticalCurveType.ActiveCurves);

            foreach (Curve curve in curveList)
            {
                curves.Append(curve);
            }

            if (null == curves || true == curves.IsEmpty)
            {
                m_errorInformation = "The program should never go here.";
                return(transform);
            }

            // Now I am sure I can create a transform instance.
            transform = Transform.Identity;

            // Third find the middle point of the floor and set it as Origin property.
            Autodesk.Revit.DB.XYZ midPoint = XYZMath.FindMiddlePoint(curves);
            transform.Origin = midPoint;

            // At last find out the directions of the created view, and set it as Basis property.
            Autodesk.Revit.DB.XYZ basisZ = XYZMath.FindFloorViewDirection(curves);
            Autodesk.Revit.DB.XYZ basisX = XYZMath.FindRightDirection(basisZ);
            Autodesk.Revit.DB.XYZ basisY = XYZMath.FindUpDirection(basisZ);

            transform.set_Basis(0, basisX);
            transform.set_Basis(1, basisY);
            transform.set_Basis(2, basisZ);
            return(transform);
        }