示例#1
0
        public void LoadPreviewIcon()
        {
            var iconCamera = RobotExporterAddInServer.Instance.Application.TransientObjects.CreateCamera();

            iconCamera.SceneObject = RobotExporterAddInServer.Instance.OpenAssemblyDocument.ComponentDefinition;

            const double zoom = 0.6;  // Zoom, where a zoom of 1 makes the camera the size of the whole robot

            const int widthConst = 3; // The image needs to be wide to hide the XYZ coordinate labels in the bottom left corner

            var occurrences = InventorUtils.GetComponentOccurrencesFromNodes(new List <RigidNode_Base> {
                node
            });

            iconCamera.Fit();
            iconCamera.GetExtents(out _, out var height);

            InventorUtils.SetCameraView(InventorUtils.GetOccurrencesCenter(occurrences), 15, height * zoom * widthConst, height * zoom, iconCamera);


            pictureBox1.Image = AxHostConverter.PictureDispToImage(
                iconCamera.CreateImage(pictureBox1.Height * widthConst, pictureBox1.Height,
                                       RobotExporterAddInServer.Instance.Application.TransientObjects.CreateColor(210, 222, 239),
                                       RobotExporterAddInServer.Instance.Application.TransientObjects.CreateColor(175, 189, 209)));
        }
示例#2
0
        public static void UseApprentice(object obj)
        {
            MainForm form1 = (MainForm)obj;

            Inventor.ApprenticeServerComponent app =
                new Inventor.ApprenticeServerComponent();

            string folder = @"C:\Users\adamnagy\Documents\Inventor";

            UpdateInfo(form1.lblInfo, "Working...");

            string [] files = Directory.GetFiles(folder, "*.ipt");
            int       i     = 0;

            foreach (string file in files)
            {
                Inventor.ApprenticeServerDocument doc =
                    app.Open(file);

                UpdateInfo(form1.lblInfo, "Working..." + (++i).ToString());

                try
                {
                    var pic = doc.Thumbnail;
                    System.Diagnostics.Debug.WriteLine("Got Thumbnail");

                    Image img = AxHostConverter.PictureDispToImage(pic);

                    form1.pictureBox.Image = null;
                    //System.Threading.Thread.Sleep(100);
                    form1.pictureBox.Image = img;
                    //System.Threading.Thread.Sleep(100);
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine("Oops");
                    UpdateInfo(form1.lblInfo, "Oops...");
                    return;
                }

                doc.Close();
            }

            UpdateInfo(form1.lblInfo, "Done");
        }