Пример #1
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static Transform ToRevit(this oM.Geometry.TransformMatrix transformMatrix)
        {
            if (transformMatrix == null)
            {
                return(null);
            }

            XYZ       basisX      = new XYZ(transformMatrix.Matrix[0, 0], transformMatrix.Matrix[1, 0], transformMatrix.Matrix[2, 0]);
            XYZ       basisY      = new XYZ(transformMatrix.Matrix[0, 1], transformMatrix.Matrix[1, 1], transformMatrix.Matrix[2, 1]);
            XYZ       basisZ      = new XYZ(transformMatrix.Matrix[0, 2], transformMatrix.Matrix[1, 2], transformMatrix.Matrix[2, 2]);
            XYZ       translation = new XYZ(transformMatrix.Matrix[0, 3].FromSI(UnitType.UT_Length), transformMatrix.Matrix[1, 3].FromSI(UnitType.UT_Length), transformMatrix.Matrix[2, 3].FromSI(UnitType.UT_Length));
            Transform transform   = Transform.CreateTranslation(translation);

            transform.set_Basis(0, basisX);
            transform.set_Basis(1, basisY);
            transform.set_Basis(2, basisZ);
            return(transform);
        }
Пример #2
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static oM.Geometry.TransformMatrix FromRevit(this Transform transform)
        {
            if (transform == null)
            {
                return(null);
            }

            oM.Geometry.TransformMatrix transformMatrix = new oM.Geometry.TransformMatrix();
            transformMatrix.Matrix[0, 0] = transform.BasisX.X;
            transformMatrix.Matrix[1, 0] = transform.BasisX.Y;
            transformMatrix.Matrix[2, 0] = transform.BasisX.Z;
            transformMatrix.Matrix[0, 1] = transform.BasisY.X;
            transformMatrix.Matrix[1, 1] = transform.BasisY.Y;
            transformMatrix.Matrix[2, 1] = transform.BasisY.Z;
            transformMatrix.Matrix[0, 2] = transform.BasisZ.X;
            transformMatrix.Matrix[1, 2] = transform.BasisZ.Y;
            transformMatrix.Matrix[2, 2] = transform.BasisZ.Z;
            transformMatrix.Matrix[0, 3] = transform.Origin.X.ToSI(UnitType.UT_Length);
            transformMatrix.Matrix[1, 3] = transform.Origin.Y.ToSI(UnitType.UT_Length);
            transformMatrix.Matrix[2, 3] = transform.Origin.Z.ToSI(UnitType.UT_Length);
            transformMatrix.Matrix[3, 3] = 1;
            return(transformMatrix);
        }