Esempio n. 1
0
        /// <summary>
        /// Converts Array from GetMatrix() to double[].
        /// </summary>
        public static double[] GetMatrix(this SolidEdgeAssembly.Occurrence occurrence)
        {
            Array matrix = Array.CreateInstance(typeof(double), 0);

            occurrence.GetMatrix(ref matrix);
            return(matrix.OfType <double>().ToArray());
        }
        static void ReportOccurrences(SolidEdgeAssembly.Occurrences occurrences)
        {
            SolidEdgeAssembly.Occurrence occurrence = null;

            Console.WriteLine();

            for (int i = 1; i <= occurrences.Count; i++)
            {
                occurrence = occurrences.Item(i);

                // Allocate a new array to hold transform.
                double[] transform = new double[6];

                // Allocate a new array to hold matrix.
                Array matrix = Array.CreateInstance(typeof(double), 16);

                // Get the occurrence transform.
                occurrence.GetTransform(
                    OriginX: out transform[0],
                    OriginY: out transform[1],
                    OriginZ: out transform[2],
                    AngleX: out transform[3],
                    AngleY: out transform[4],
                    AngleZ: out transform[5]);

                // Get the occurrence matrix.
                occurrence.GetMatrix(ref matrix);

                // Convert from System.Array to double[].  double[] is easier to work with.
                double[] m = matrix.OfType <double>().ToArray();

                // Report the occurrence transform.
                Console.WriteLine("{0} transform:", occurrence.Name);
                Console.WriteLine("OriginX: {0} (meters)", transform[0]);
                Console.WriteLine("OriginY: {0} (meters)", transform[1]);
                Console.WriteLine("OriginZ: {0} (meters)", transform[2]);
                Console.WriteLine("AngleX: {0} (radians)", transform[3]);
                Console.WriteLine("AngleY: {0} (radians)", transform[4]);
                Console.WriteLine("AngleZ: {0} (radians)", transform[5]);
                Console.WriteLine();

                // Report the occurrence matrix.
                Console.WriteLine("{0} matrix:", occurrence.Name);
                Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                  m[0],
                                  m[1],
                                  m[2],
                                  m[3]);
                Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                  m[4],
                                  m[5],
                                  m[6],
                                  m[7]);
                Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                  m[8],
                                  m[9],
                                  m[10],
                                  m[11]);
                Console.WriteLine("|{0}, {1}, {2}, {3}|",
                                  m[12],
                                  m[13],
                                  m[14],
                                  m[15]);

                Console.WriteLine();
            }
        }