Exemplo n.º 1
0
        /// <summary>
        /// Finds a document in the active assembly
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static InventorDocument GetDocument(string name)
        {
            // Set an initial value to return
            InventorDocument documentToReturn = null;

            if (InventorApplication.ActiveDocument == null)
            {
                throw new Exception("Must have an open document");
            }

            // if an assembly document then parse the document
            if (InventorApplication.ActiveDocument.IsAssemblyDoc)
            {
                var adoc = InventorApplication.ActiveDocument.GetAssemblyDocument();

                // if the active document matches the name then return the active
                if (name == System.IO.Path.GetFileNameWithoutExtension(adoc.Name))
                {
                    documentToReturn = InventorApplication.ActiveDocument;
                }
                else
                {
                    // Search the document in the referenced documents within the assembly
                    documentToReturn = adoc.GetReferencedDocument(name);
                }
            }
            // if it is a part doc then return the active document
            else if (InventorApplication.ActiveDocument.IsPartDoc)
            {
                documentToReturn = InventorApplication.ActiveDocument;
            }

            return(documentToReturn);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Searches the assembly for the referenced document
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public InventorDocument GetReferencedDocument(string name)
        {
            InventorDocument tempdoc = null;

            foreach (Document doc in _adoc.AllReferencedDocuments)
            {
                if (System.IO.Path.GetFileNameWithoutExtension(doc.FullFileName) == name)
                {
                    tempdoc = new InventorDocument(doc);

                    break;
                }
            }

            return(tempdoc);
        }