public void AddAssemblyBrowserFolder() { AssemblyDocument oDoc = (AssemblyDocument)_InvApplication.ActiveDocument; AssemblyComponentDefinition oDef = oDoc.ComponentDefinition; BrowserPane oPane = default(BrowserPane); oPane = oDoc.BrowserPanes.ActivePane; // Create an object collection ObjectCollection oOccurrenceNodes = default(ObjectCollection); oOccurrenceNodes = _InvApplication.TransientObjects.CreateObjectCollection(); foreach (ComponentOccurrence oOcc in oDef.Occurrences) { // Get the node associated with this occurrence. BrowserNode oNode = default(BrowserNode); oNode = oPane.GetBrowserNodeFromObject(oOcc); // Add the node to the collection. oOccurrenceNodes.Add(oNode); } // Add the folder to the browser and specify the nodes to be grouped within it. BrowserFolder oFolder = default(BrowserFolder); oFolder = oPane.AddBrowserFolder("My Occurrences Folder", oOccurrenceNodes); }
private BrowserFolder getFolderForFile(BrowserPane browserPane, string searchedFileName) { BrowserFolder folder = null; foreach (BrowserFolder curentFolder in browserPane.TopNode.BrowserFolders) { foreach (BrowserNode node in curentFolder.BrowserNode.BrowserNodes) { if (node.NativeObject is ComponentOccurrence) { ComponentOccurrence occ = (ComponentOccurrence)node.NativeObject; string currentFileName = occ.ReferencedFileDescriptor.FullFileName; if (!searchedFileName.Equals(currentFileName, StringComparison.InvariantCultureIgnoreCase)) { continue; } } else { continue; } folder = curentFolder; break; } } if (folder == null) { ObjectCollection colNodes = inventor.TransientObjects.CreateObjectCollection(); folder = browserPane.AddBrowserFolder("temp", colNodes); } return(folder); }