Beispiel #1
0
        private void OpenButton_Click(object sender, EventArgs e)
        {
            if (((mCurrentDoc != null)))
            {
                mCurrentDoc.Close();
            }

            string filename = OpenFile();


            if ((!string.IsNullOrEmpty(filename)))
            {
                mCurrentDoc = mApprenticeServer.Open(filename);


                if ((mCurrentDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject))
                {
                    mCurrentDrawingDoc = (ApprenticeServerDrawingDocument)mCurrentDoc;
                }


                IPictureDisp oPicDisp = (IPictureDisp)mCurrentDoc.Thumbnail;
                Image        image    = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(oPicDisp);

                //image.Save("c:\Temp\Thumbnail.bmp", System.Drawing.Imaging.ImageFormat.Bmp)

                PreviewPic.Image = image;
                PreviewPic.Refresh();

                lbFilename.Text = "File: " + mCurrentDoc.DisplayName;

                ViewerButton.Enabled = true;
            }
        }
Beispiel #2
0
        private void OpenDocument()
        {
            if (!System.IO.File.Exists(this._filePath))
            {
                throw new ArgumentNullException("filepath donot exists");
            }
            if (_oserver == null)
            {
                throw new ArgumentNullException("oserver isnot initialized");
            }
            if (_HWnd == 0)
            {
                throw new ArgumentNullException("hwnd isnot initialized");
            }

            _odocument = _oserver.Open(this._filePath);
            if (_odocument.DocumentType == DocumentTypeEnum.kDrawingDocumentObject)
            {
                _odrawingDocument = (Inventor.ApprenticeServerDrawingDocument)_odocument;
                _oview            = _odrawingDocument.Sheets[1].ClientViews.Add(this.HWnd);
                _ocamera          = _oview.Camera;
                _ocamera.Fit();
                _ocamera.Apply();
                _ocamera.Perspective = false;
            }
            else
            {
                _oview   = _odocument.ClientViews.Add(this.HWnd);
                _ocamera = _oview.Camera;
                _ocamera.Fit();
                _ocamera.Apply();
                _ocamera.ViewOrientationType = ViewOrientationTypeEnum.kBackViewOrientation;
            }
        }
Beispiel #3
0
 private void CloseDocument()
 {
     if (_odocument != null)
     {
         _odocument.Close();
         _odocument = null;
     }
     if (_odrawingDocument != null)
     {
         _odrawingDocument.Close();
         _odrawingDocument = null;
     }
 }
        private void buttonBrowse_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();

            fdlg.Title            = "C# Inventor Open File Dialog";
            fdlg.InitialDirectory = @"c:\program files\autodesk\inventor 2013\samples\models\";
            fdlg.Filter           = "Inventor files (*.ipt; *.iam; *.idw)|*.ipt;*.iam;*.idw";
            fdlg.FilterIndex      = 2;
            fdlg.RestoreDirectory = true;
            if (fdlg.ShowDialog() == DialogResult.OK)
            {
                // get the file name
                textBoxFileName.Text = fdlg.FileName;
                m_odocument          = m_oserver.Open(textBoxFileName.Text);

                // if drawing document, get the first sheet and from it the client views collection, then create a client view
                if (m_odocument.DocumentType == DocumentTypeEnum.kDrawingDocumentObject)
                {
                    m_odrawingDocument = (Inventor.ApprenticeServerDrawingDocument)m_odocument;

                    m_oview = m_odrawingDocument.Sheets[1].ClientViews.Add(pictureBox1.Handle.ToInt32());

                    m_ocamera             = m_oview.Camera;
                    m_ocamera.Perspective = false;
                }
                // if part or assembly get the client views collection from the document, then create a client view
                else
                {
                    m_oview = m_odocument.ClientViews.Add(pictureBox1.Handle.ToInt32());

                    m_ocamera = m_oview.Camera;
                    m_ocamera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation;
                }

                m_ocamera.Fit();
                m_ocamera.Apply();

                m_oview.Update(false);

                // using the control to display the file
                axInventorView1.FileName = fdlg.FileName;
            }
        }
Beispiel #5
0
        private void OpenButton_Click(object sender, EventArgs e)
        {
            if (((mCurrentDoc != null)))
            {
                mCurrentDoc.Close();
            }

            string filename = OpenFile();


            if ((!string.IsNullOrEmpty(filename)))
            {
                mCurrentDoc = mApprenticeServer.Open(filename);


                if ((mCurrentDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject))
                {
                    mCurrentDrawingDoc = (ApprenticeServerDrawingDocument)mCurrentDoc;
                }


                IPictureDisp oPicDisp = (IPictureDisp)mCurrentDoc.Thumbnail;
                Image image = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(oPicDisp);

                //image.Save("c:\Temp\Thumbnail.bmp", System.Drawing.Imaging.ImageFormat.Bmp)

                PreviewPic.Image = image;
                PreviewPic.Refresh();

                lbFilename.Text = "File: " + mCurrentDoc.DisplayName;

                ViewerButton.Enabled = true;
            }


        }