Ejemplo n.º 1
0
        static InstancePathArray GetAllPartInstances(IntPtr po, InstancePath owners)
        {
            InstancePathArray result = new InstancePathArray();
            var current_owners       = new InstancePath(owners);

            current_owners.Add(po);

            var part = GetPartDefinition(po);

            if (IntPtr.Zero != part)
            {
                current_owners.Add(part);
                result.Add(current_owners);
                return(result);
            }

            var po_data = new A3DAsmProductOccurrenceWrapper(po);

            for (var idx = 0; idx < po_data.m_uiPOccurrencesSize; ++idx)
            {
                var child_po    = Marshal.ReadIntPtr(po_data.m_ppPOccurrences, idx * Marshal.SizeOf(typeof(IntPtr)));
                var child_paths = GetAllPartInstances(child_po, current_owners);
                result.AddRange(child_paths);
            }

            return(result);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string exchange_folder = null;
            string input_file      = null;

            for (var arg = 0; arg < args.Length; ++arg)
            {
                if (arg < args.Length - 1)
                {
                    if (args[arg] == "--exchange")
                    {
                        exchange_folder = args[++arg];
                        continue;
                    }
                }
                input_file = args[arg];
            }

            if (null == input_file)
            {
                Console.WriteLine("Please provide an input file as an argument.");
                return;
            }


            try {
                Library.Initialize(HOOPS_LICENSE.KEY, exchange_folder);
            } catch (Library.InitializationException e) {
                Console.WriteLine(e.Message);
                return;
            }

            A3DRWParamsLoadData load_params;

            API.Initialize(out load_params);
            IntPtr model_file;

            if (A3DStatus.A3D_SUCCESS != API.A3DAsmModelFileLoadFromFile(input_file, ref load_params, out model_file))
            {
                Console.WriteLine("Failed to load input file.");
                return;
            }

            var          model_file_data = new A3DAsmModelFileWrapper(model_file);
            InstancePath owners          = new InstancePath();

            owners.Add(model_file);
            var po     = Marshal.ReadIntPtr(model_file_data.m_ppPOccurrences);
            var result = GetAllPartInstances(po, owners);

            Console.WriteLine("There are " + result.Count + " part instances.");
        }