private void ExportBySelSets(SavedItem item, Document doc) { if (item is FolderItem) { //рекурсивный вызов для каждого вложенного FolderItem folder = item as FolderItem; foreach (SavedItem nestedItem in folder.Children) { ExportBySelSets(nestedItem, doc); } } else if (item is SelectionSet) { SelectionSet selectionSet = item as SelectionSet; ModelItemCollection itemsToExport = selectionSet.GetSelectedItems(); if (itemsToExport.DescendantsAndSelf.Count() > 0) { ModelItemCollection itemsToHide = new ModelItemCollection(itemsToExport); itemsToHide.Invert(doc); doc.Models.SetHidden(itemsToHide, true); doc.Models.SetHidden(itemsToExport, false); FBXExport.FBXFileName = selectionSet.DisplayName + ".fbx"; S1NF0_RibbonPanel.ExecuteAddInPlugin("FBXExport." + DEVELOPER_ID); doc.Models.SetHidden(itemsToHide, false); } } }
private void StructureFilling(XML.St.Object parent, SavedItem item, StructureDataStorage dataStorage, Document doc) { if (item is FolderItem) { FolderItem folder = item as FolderItem; XML.St.Object container = dataStorage.CreateNewContainerObject(parent, folder.DisplayName); foreach (SavedItem nestedItem in folder.Children) { StructureFilling(container, nestedItem, dataStorage, doc); } } else if (item is SelectionSet) { SelectionSet selectionSet = item as SelectionSet; XML.St.Object container = dataStorage.CreateNewContainerObject(parent, selectionSet.DisplayName); ModelItemCollection itemsInSelection = selectionSet.GetSelectedItems(); Search searchForAllIDs = new Search(); searchForAllIDs.Selection.CopyFrom(itemsInSelection); searchForAllIDs.Locations = SearchLocations.DescendantsAndSelf; StructureDataStorage.ConfigureSearchForAllGeometryItemsWithIds(searchForAllIDs, false); ModelItemCollection selectedGeometry = searchForAllIDs.FindAll(doc, false); foreach (ModelItem modelItem in selectedGeometry) { dataStorage.CreateNewModelObject(container, modelItem); } } }
/// <summary> /// Apply appearance to selection set /// </summary> /// <param name="selectionSet"></param> /// <param name="color"></param> /// <param name="transparency"></param> private void ApplyAppearance(SelectionSet selectionSet, Color color, double transparency) { if (selectionSet != null && color != null) { IEnumerable <ModelItem> modelItems = selectionSet.GetSelectedItems() as IEnumerable <ModelItem>; Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(modelItems, color); Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentTransparency(modelItems, transparency); } }