Beispiel #1
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");
        }
    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");
    }
Beispiel #3
0
        public static void GetUserDefProperties(string mPath, ref string[] mName, ref string[] mVal)
        {
            Inventor.Property    oProp;
            Inventor.PropertySet oPropSet;
            int mArrIndex = 0;

            Inventor.ApprenticeServerComponent oApprenticeApp = new Inventor.ApprenticeServerComponent();
            Inventor.ApprenticeServerDocument  oApprenticeServerDoc;
            oApprenticeServerDoc = oApprenticeApp.Open(mPath);
            if (oApprenticeServerDoc == null)
            {
                MessageBox.Show("File không hợp lệ");
                return;
            }
            foreach (Inventor.PropertySet tempLoopVar_oPropSet in oApprenticeServerDoc.PropertySets)
            {
                oPropSet = tempLoopVar_oPropSet;
                if (oPropSet.DisplayName == "User Defined Properties")
                {
                    mArrIndex = 0;
                    mName     = new string[oPropSet.Count + 1];
                    mVal      = new string[oPropSet.Count + 1];
                    foreach (Inventor.Property tempLoopVar_oProp in oPropSet)
                    {
                        oProp = tempLoopVar_oProp;

                        if (oProp.Name.ToLower().StartsWith("plot"))
                        {
                            continue;
                        }

                        if (Information.VarType(oProp.Value) != Constants.vbDate)
                        {
                            mName[mArrIndex] = (string)oProp.Name;
                            mVal[mArrIndex]  = (string)oProp.Value;
                            mArrIndex++;
                        }
                    }
                    break;
                }
            }
        }