예제 #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;
            }
        }
예제 #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;
            }
        }
        public Form1()
        {
            // Try to create an instance of apprentice server
            try
            {
                m_oserver = new ApprenticeServerComponent();
                AddInventorPath();
            }
            catch (SystemException exception)
            {
                MessageBox.Show(this,
                                "Failed to create an instance of Apprentice server.",
                                "CSharpFileDisplaySample",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            m_odocument  = null;
            m_oview      = null;
            m_ocamera    = null;
            m_bmouseDown = false;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
        }
예제 #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            mApprenticeServer    = new ApprenticeServerComponent();
            ViewerButton.Enabled = false;

            PreviewPic.SizeMode = PictureBoxSizeMode.StretchImage;

            mCurrentDoc = null;
        }
예제 #5
0
 private void CloseDocument()
 {
     if (_odocument != null)
     {
         _odocument.Close();
         _odocument = null;
     }
     if (_odrawingDocument != null)
     {
         _odrawingDocument.Close();
         _odrawingDocument = null;
     }
 }
예제 #6
0
        // set property [Author]
        private void SetProperty(string author)
        {
            ApprenticeServerDocument oApprenticeDoc = default(ApprenticeServerDocument);

            oApprenticeDoc = mApprenticeServer.Open(OpenFile());

            //Get "Inventor Summary Information" PropertySet
            PropertySet oPropertySet = oApprenticeDoc.PropertySets["{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"];

            //Get Author property
            InventorApprentice.Property oProperty = oPropertySet["Author"];

            oProperty.Value = author;

            oApprenticeDoc.PropertySets.FlushToFile();
            oApprenticeDoc.Close();
        }
예제 #7
0
        private void SaveRec(ref string NewFolder, ref ApprenticeServerDocument oApprenticeDoc)
        {
            string NewFullFilename = NewFolder + newFileName(oApprenticeDoc.FullFileName);

            try
            {
                mApprenticeApp.FileSaveAs.AddFileToSave(oApprenticeDoc, NewFullFilename);
                ApprenticeServerDocument oRefDoc;
                for (int i = 1; i <= oApprenticeDoc.ReferencedDocuments.Count; i++)
                {
                    oRefDoc = oApprenticeDoc.ReferencedDocuments[i];
                    SaveRec(ref NewFolder, ref oRefDoc);
                }
            }
            catch
            {
                //Content Center Parts will fail
            }
        }
        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;
            }
        }
예제 #9
0
        void watcher_Created(object sender, FileSystemEventArgs e)
        {
            // A file got created. Let's check its iProperties
            string iProperties = "File path: " + e.FullPath + "\r\n";

            // We might not always be able to open a document, e.g.
            // maybe if the writer locked it, so let's catch any errors
            try
            {
                ApprenticeServerComponent app = new ApprenticeServerComponent();
                ApprenticeServerDocument  doc = app.Open(e.FullPath);

                // Gather "Summary Information" properties
                PropertySet ps = doc.PropertySets["{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"];
                foreach (Property p in ps)
                {
                    // e.g. the Thumbnail property cannot be converted to string
                    // so that would throw an error we need to catch
                    try
                    {
                        iProperties += p.DisplayName + ": " + p.Value.ToString() + "\r\n";
                    }
                    catch { }
                }

                app.Close();
                app = null;
            }
            catch (Exception ex)
            {
                iProperties += "Exception occurred: " + ex.Message + "\r\n";
            }

            // Write it to the file
            using (StreamWriter sw = System.IO.File.AppendText(logFile))
            {
                sw.Write(iProperties);
            }
        }
예제 #10
0
        static void Main(string[] args)
        {
            try
            {
                var filePath = args[0];

                if (!System.IO.File.Exists(filePath))
                {
                    System.Console.Write(
                        string.Format("File ({0}) does not exist.", filePath));

                    return;
                }

                ApprenticeServerComponent asc = new ApprenticeServerComponent();
                ApprenticeServerDocument  asd = asc.Open(filePath);

                // "Inventor Summary Information"
                PropertySet ps = asd
                                 .PropertySets["{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"];

                foreach (Property p in ps)
                {
                    System.Console.Write(
                        string.Format("{0}={1};",
                                      p.DisplayName,
                                      p.Value)
                        );
                }

                asd.Close();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
예제 #11
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;
            }


        }
예제 #12
0
        private void SaveRec(ref string NewFolder, ref ApprenticeServerDocument oApprenticeDoc)
        {
            string NewFullFilename = NewFolder + newFileName(oApprenticeDoc.FullFileName);

            try
            {
                mApprenticeApp.FileSaveAs.AddFileToSave(oApprenticeDoc, NewFullFilename);
                ApprenticeServerDocument oRefDoc;
                for (int i = 1; i <= oApprenticeDoc.ReferencedDocuments.Count;i++ )
                {
                    oRefDoc = oApprenticeDoc.ReferencedDocuments[i];
                    SaveRec(ref NewFolder, ref oRefDoc);
                }

            }
            catch
            {
                //Content Center Parts will fail
            }
        }
예제 #13
0
        //TODO: MakeInvCopy is going to be called over and over again by DesignScript, not us, so there is no opportunity to pass the count into this method.
        //UniqueModuleEvaluator needs to be modified each time this is called so we know which module we are on.

        //TODO:  ApprenticeServer instance creation and lifetime management needs to be handled by InventorServices.Persistance

        //TODO: OccurrenceList needs to be set on each Module instance during UniqueModuleEvaluator's construction.

        //TODO: Refactor this method, it is so big.
        private void MakeInvCopy(ApprenticeServer appServ,
                                 string templateAssemblyPath,
                                 string templateDrawingPath,
                                 string targetDirectory,
                                 OccurrenceList occList,
                                 int count,
                                 UniqueModuleEvaluator uniqueModuleEvaluator)
        {
            // TODO Test for the existance of folders and assemblies.
            ApprenticeServer oAppServ = appServ;
            int            panelID    = count;
            OccurrenceList oOccs      = occList;
            string         topFileFullName;
            string         targetPath = targetDirectory;

            TemplateAssemblyPath = templateAssemblyPath;
            TemplateDrawingPath  = templateDrawingPath;
            string panelIDString = System.Convert.ToString(panelID);

            UniqueModules = uniqueModuleEvaluator;

            //Instead of using "panelID" to create unique folders for all instances, redirect to the GeometryMapIndex
            string geoMapString = System.Convert.ToString(GeometryMapIndex);
            string folderName;

            if (CreateAllCopies == false)
            {
                if (GeometryMapIndex < 10)
                {
                    folderName = System.IO.Path.GetFileNameWithoutExtension(TemplateAssemblyPath) + " 00" + geoMapString;
                }

                else if (10 <= GeometryMapIndex && GeometryMapIndex < 100)
                {
                    folderName = System.IO.Path.GetFileNameWithoutExtension(TemplateAssemblyPath) + " 0" + geoMapString;
                }
                else
                {
                    folderName = System.IO.Path.GetFileNameWithoutExtension(TemplateAssemblyPath) + " " + geoMapString;
                }
            }

            else
            {
                if (panelID < 10)
                {
                    folderName = System.IO.Path.GetFileNameWithoutExtension(TemplateAssemblyPath) + " 00" + panelIDString;
                }
                else if (10 <= panelID && panelID < 100)
                {
                    folderName = System.IO.Path.GetFileNameWithoutExtension(TemplateAssemblyPath) + " 0" + panelIDString;
                }
                else
                {
                    folderName = System.IO.Path.GetFileNameWithoutExtension(TemplateAssemblyPath) + " " + panelIDString;
                }
            }
            //if(panelID < 10){
            //Need to get number of the parent occ, top level name as foldername
            string pathString = System.IO.Path.Combine(targetPath, folderName);

            topFileFullName = oOccs.TargetAssembly.FullDocumentName;
            string topFileNameOnly = System.IO.Path.GetFileName(topFileFullName);

            ModulePath = System.IO.Path.Combine(pathString, topFileNameOnly);


            TupleList <string, string> filePathPair = new TupleList <string, string>();

            for (int i = 0; i < occList.Items.Count; i++)
            {
                string targetOccPath   = occList.Items[i].ReferencedFileDescriptor.FullFileName;
                string newCopyName     = System.IO.Path.GetFileName(targetOccPath);
                string newFullCopyName = System.IO.Path.Combine(pathString, newCopyName);
                filePathPair.Add(targetOccPath, newFullCopyName);
            }

            //Check if an earlier panel already made the folder, if not, create it.
            if (!System.IO.Directory.Exists(pathString))
            {
                firstTime = true;
                System.IO.Directory.CreateDirectory(pathString);
                //AssemblyReplaceRef(oAppServ, oOccs.TargetAssembly, filePathPair, pathString);
                ApprenticeServerDocument oAssDoc;
                oAssDoc = oAppServ.Open(TemplateAssemblyPath);
                FileSaveAs fileSaver;
                fileSaver = oAppServ.FileSaveAs;
                fileSaver.AddFileToSave(oAssDoc, ModulePath);
                fileSaver.ExecuteSaveCopyAs();

                //Need to copy presentation files if there are any.  For now this is only going to work with the top assembly.
                string   templateDirectory = System.IO.Path.GetDirectoryName(TemplateAssemblyPath);
                string[] presentationFiles = System.IO.Directory.GetFiles(templateDirectory, "*.ipn");
                //If we want the ability to have subassemblies with .ipn files or multiple ones, this will have to be changed
                //to iterate over all the .ipn files.
                if (presentationFiles.Length != 0)
                {
                    string newCopyPresName     = System.IO.Path.GetFileName(presentationFiles[0]);
                    string newFullCopyPresName = System.IO.Path.Combine(pathString, newCopyPresName);

                    ApprenticeServerDocument      presentationDocument = oAppServ.Open(presentationFiles[0]);
                    DocumentDescriptorsEnumerator presFileDescriptors  = presentationDocument.ReferencedDocumentDescriptors;
                    foreach (DocumentDescriptor refPresDocDescriptor in presFileDescriptors)
                    {
                        if (refPresDocDescriptor.FullDocumentName == TemplateAssemblyPath)
                        {
                            refPresDocDescriptor.ReferencedFileDescriptor.ReplaceReference(ModulePath);
                            FileSaveAs fileSavePres;
                            fileSavePres = oAppServ.FileSaveAs;
                            fileSavePres.AddFileToSave(presentationDocument, newFullCopyPresName);
                        }
                    }
                }

                string newCopyDrawingName     = System.IO.Path.GetFileName(TemplateDrawingPath);
                string newFullCopyDrawingName = System.IO.Path.Combine(pathString, newCopyDrawingName);

                if (TemplateDrawingPath != "")
                {
                    ApprenticeServerDocument      drawingDoc             = oAppServ.Open(TemplateDrawingPath);
                    DocumentDescriptorsEnumerator drawingFileDescriptors = drawingDoc.ReferencedDocumentDescriptors;
                    //This needs to be fixed.  It was written with the assumption that only the template assembly would be in
                    //the details and be first in the collection of document descriptors.  Need to iterate through
                    //drawingFileDescriptors and match names and replace correct references.
                    //Possibly can use the "filePathPair" object for name matching/reference replacing.
                    //drawingFileDescriptors[1].ReferencedFileDescriptor.ReplaceReference(topAssemblyNewLocation);
                    foreach (DocumentDescriptor refDocDescriptor in drawingFileDescriptors)
                    {
                        foreach (Tuple <string, string> pathPair in filePathPair)
                        {
                            string newFileNameLower      = System.IO.Path.GetFileName(pathPair.Item2);
                            string drawingReferenceLower = System.IO.Path.GetFileName(refDocDescriptor.FullDocumentName);
                            string topAssemblyLower      = System.IO.Path.GetFileName(ModulePath);
                            if (topAssemblyLower == drawingReferenceLower)
                            {
                                refDocDescriptor.ReferencedFileDescriptor.ReplaceReference(ModulePath);
                            }
                            if (newFileNameLower == drawingReferenceLower)
                            {
                                refDocDescriptor.ReferencedFileDescriptor.ReplaceReference(pathPair.Item2);
                            }
                        }
                    }

                    FileSaveAs fileSaveDrawing;
                    fileSaveDrawing = oAppServ.FileSaveAs;
                    fileSaveDrawing.AddFileToSave(drawingDoc, newFullCopyDrawingName);
                    fileSaveDrawing.ExecuteSaveCopyAs();
                    firstTime = true;

                    if (!UniqueModules.DetailDocumentPaths.Contains(newFullCopyDrawingName))
                    {
                        UniqueModules.DetailDocumentPaths.Add(newFullCopyDrawingName);
                    }
                }
            }
        }
예제 #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
               mApprenticeServer = new ApprenticeServerComponent();
            ViewerButton.Enabled = false;

            PreviewPic.SizeMode = PictureBoxSizeMode.StretchImage;

            mCurrentDoc = null;

        }
예제 #15
0
        static void Main(string[] args)
        {
            Console.BufferWidth = 300;
            Console.WindowWidth = 140;
            string msg = String.Format("coolOrange bcpMaker v{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);

            Console.WriteLine(msg);
            Console.WriteLine("".PadRight(msg.Length, '*'));
            if (System.IO.File.Exists("bcpMaker.log"))
            {
                System.IO.File.Delete("bcpMaker.log");
            }
            System.IO.File.AppendAllLines("bcpMaker.log", new string[] { msg });
            if (!System.IO.File.Exists("config.xml"))
            {
                Console.WriteLine("config.xml file could not be found nearby the bcpMaker.exe");
                Console.ReadKey();
                return;
            }
            XmlDocument config = new XmlDocument();

            try
            {
                config.Load("config.xml");
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Error loading config.xml: {0}", ex));
                Console.ReadKey();
                return;
            }

            var    parameters    = config.SelectSingleNode("//PARAMETERS");
            string sourceFolder  = parameters.Attributes["SourceFilesFolder"].Value;
            string targetFolder  = parameters.Attributes["TargetBCPFolder"].Value;
            var    ignore        = config.SelectSingleNode("//IGNORE");
            string ignoreFolder  = ignore.Attributes["Folders"].Value;
            string ignoreFiles   = ignore.Attributes["FileExtensions"].Value;
            var    categoryRules = config.SelectNodes("//CATEGORYRULE");

            System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("Source folder: {0} ", sourceFolder) });
            System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("target folder: {0} ", sourceFolder) });
            System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("ignore file extensions: {0} ", ignoreFiles) });
            System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("ignore folder: {0} ", ignoreFolder) });
            if (!System.IO.Directory.Exists(sourceFolder))
            {
                Console.WriteLine(String.Format("source folder '{0}' does not exist", sourceFolder));
                Console.ReadKey();
                return;
            }
            try
            {
                System.IO.Directory.CreateDirectory(targetFolder);
            }
            catch
            {
                Console.WriteLine(String.Format("target folder '{0}' could not be created", targetFolder));
                Console.ReadKey();
                return;
            }

            #region apprentice server initialization
            ApprenticeServerComponent _invApp         = new ApprenticeServerComponent();
            DesignProject             InventorProject = _invApp.DesignProjectManager.ActiveDesignProject;
            List <string>             libraryFolders  = new List <string>();
            string ccPath = InventorProject.ContentCenterPath;
            libraryFolders.Add(ccPath.Replace(sourceFolder, ""));
            string workSpace = InventorProject.WorkspacePath;
            workSpace = workSpace.Replace(sourceFolder, "");
            var libraryPaths = InventorProject.LibraryPaths;
            msg = String.Format("Using Inventor Project File '{0}'", InventorProject.FullFileName);
            Console.WriteLine(msg);
            System.IO.File.AppendAllLines("bcpMaker.log", new string[] { msg });
            ProjectPaths libPaths = InventorProject.LibraryPaths;
            foreach (ProjectPath libpath in libPaths)
            {
                libraryFolders.Add(libpath.Path.TrimStart('.').Replace("\\", "/"));
            }
            #endregion

            List <string> files = new List <string>();
            Console.WriteLine("Scanning folders...");
            GetAllFilesFromFolderRecursively(sourceFolder, files, ignoreFiles, ignoreFolder);
            Console.WriteLine(String.Format("\rCollected files {0}", files.Count).PadRight(Console.BufferWidth, ' '));

            #region adding files to BCP package
            Console.WriteLine("Adding files to BCP package...");
            var bcpSvcBuilder = new BcpServiceBuilder {
                Version = BcpVersion._2016
            };
            bcpSvcBuilder.SetPackageLocation(targetFolder);
            var bcpSvc = bcpSvcBuilder.Build();

            int counter = 1;
            Dictionary <string, FileObject> bcpInventorFiles = new Dictionary <string, FileObject>(StringComparer.OrdinalIgnoreCase);

            foreach (string file in files)
            {
                string vaultTarget = file.Replace(sourceFolder, "$").Replace("\\", "/");
                bool   isLibrary   = libraryFolders.Any(lf => vaultTarget.Contains(lf.Replace("\\", "/")));
                var    bcpFile     = bcpSvc.FileService.AddFile(vaultTarget, file, isLibrary);
                string extension   = System.IO.Path.GetExtension(file);
                foreach (XmlNode categoryRule in categoryRules)
                {
                    var fileExtensions      = categoryRule.SelectSingleNode("//FILEEXTENSION");
                    var category            = categoryRule.SelectSingleNode("//CATEGORY");
                    var lifecycleDefinition = categoryRule.SelectSingleNode("//LIFECYCLEDEFINITON");
                    var state              = categoryRule.SelectSingleNode("//STATE");
                    var revision           = categoryRule.SelectSingleNode("//REVISION");
                    var revisionDefinition = categoryRule.SelectSingleNode("//REVISIONDEFINITION");
                    if (fileExtensions != null && (fileExtensions.InnerText == "" || fileExtensions.InnerText.Split(',').Contains(extension)))
                    {
                        if (category != null && category.InnerText != "")
                        {
                            bcpFile.Category = category.InnerText;
                        }
                        string stateName = state != null ? state.InnerText : "";
                        if (lifecycleDefinition != null && lifecycleDefinition.InnerText != "")
                        {
                            bcpFile.LatestIteration.Setstate(lifecycleDefinition.InnerText, stateName);
                        }
                        bcpFile.LatestRevision.SetRevisionDefinition(revisionDefinition != null ? revisionDefinition.InnerText : "", revision != null ? revision.InnerText : "");
                        break;
                    }
                }
                if (file.ToLower().EndsWith("iam") || file.ToLower().EndsWith("ipt") || file.ToLower().EndsWith("idw") || file.ToLower().EndsWith("ipn") || file.ToLower().EndsWith("dwg"))
                {
                    bcpInventorFiles.Add(file, bcpFile);
                    System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("Adding to reference check list: {0}", file) });
                }
                msg = String.Format("\rAdding file {0} of {1} to BCP package", counter++, files.Count());
                Console.Write(msg);
            }
            Console.WriteLine(String.Format("\rAdded files {0}", bcpSvc.EntitiesTable.Vault.Statistics.Totfiles).PadRight(Console.BufferWidth, ' '));
            #endregion


            var inventorFiles = files.Where(file => file.ToLower().EndsWith("iam") || file.ToLower().EndsWith("ipt") || file.ToLower().EndsWith("idw") || file.ToLower().EndsWith("ipn") || file.ToLower().EndsWith("dwg")).ToList();
            Console.WriteLine("Building references for Inventor files...");
            counter = 0;
            foreach (string iFile in inventorFiles)
            {
                msg = String.Format("\r{1}/{2}: Building references and properties for {0}", iFile, counter++, inventorFiles.Count);
                Console.Write(msg.PadRight(Console.BufferWidth, ' '));
                ApprenticeServerDocument doc = null;
                try
                {
                    doc = _invApp.Open(iFile);
                }
                catch (Exception ex)
                {
                    msg = String.Format("\r\nOpen ERROR!File {0} could not be opened", iFile);
                    Console.WriteLine(msg);
                    System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("{0}\r\n{1}", msg, ex) });
                    continue;
                }
                var    bcpParent          = bcpInventorFiles[iFile];
                string databaseRevisionID = "";
                string lastSavedLocation  = "";
                object indices            = null;
                object oldPaths           = null;
                object currentPaths       = null;
                try {
                    doc._GetReferenceInfo(out databaseRevisionID, out lastSavedLocation, out indices, out oldPaths, out currentPaths, true);
                }
                catch (Exception ex)
                {
                    msg = String.Format("\r\nRead ERROR!References for file {0} could not retrieved", iFile);
                    Console.WriteLine(msg);
                    System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("{0}\r\n{1}", msg, ex) });
                    continue;
                }

                string[] refs = currentPaths as string[];
                int[]    idx  = indices as int[];
                for (int i = 0; i < refs.Count(); i++)
                {
                    string child = refs[i];
                    if (child == null)
                    {
                        msg = String.Format("\r\nReference Warning!Reference {0} not found for assembly {1}", (oldPaths as string[])[i], iFile);
                        Console.WriteLine(msg);
                        System.IO.File.AppendAllLines("bcpMaker.log", new string[] { msg });
                        continue;
                    }
                    System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("Reference {0}", child) });

                    if (bcpInventorFiles.ContainsKey(child))
                    {
                        var bcpChild = bcpInventorFiles[child];
                        var assoc    = bcpParent.LatestIteration.AddAssociation(bcpChild.LatestIteration, AssociationObject.AssocType.Dependency);
                        assoc.refId           = idx[i].ToString();
                        assoc.needsresolution = true;
                    }
                    else
                    {
                        msg = String.Format("\rPackage ERROR!Child {0} not in bcp package for assembly {1}", (oldPaths as string[])[i], iFile);
                        Console.WriteLine(msg);
                        System.IO.File.AppendAllLines("bcpMaker.log", new string[] { msg });
                    }
                }
                string propName = "";
                try
                {
                    foreach (PropertySet propSet in doc.PropertySets)
                    {
                        foreach (Property prop in propSet)
                        {
                            propName = prop.Name;
                            if (!propName.Equals("Thumbnail") && !propName.Equals("Part Icon") && prop.Value != null)
                            {
                                bcpParent.LatestIteration.AddProperty(prop.DisplayName, prop.Value.ToString());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    msg = String.Format("\r\nProperty ERROR!Property {1} for file {0} could not be retrieved", iFile, propName);
                    Console.WriteLine(msg);
                    System.IO.File.AppendAllLines("bcpMaker.log", new string[] { String.Format("{0}\r\n{1}", msg, ex) });
                }
                doc.Close();
            }
            _invApp.Close();

            bcpSvc.Flush();
            System.Diagnostics.Process.Start(targetFolder);
        }