public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { NLogger.Initialize(); NLogger.LogText("Entered Execute method"); ConfigUtilities.LoadConfig(); LanguageHandler.Init(); uiapp = commandData.Application; doc = uiapp.ActiveUIDocument.Document; revElementHandler = new RevitElementsHandler(uiapp); revFilterHandler = new RevitFiltersHandler(); IList <Element> selectedElements = new List <Element>(); try { var win = CheckOpened("Offsite Panel"); if (win != null) { //elementWindow = win; //elementWindow.Show(); //elementWindow.Focus(); win.Close(); } elementWindow = new OffsiteForm(selectedElements, uiapp, RevitElementSelectionMode.FromFilters); elementWindow.Show(); NLogger.LogText("Exit Execute method with Success"); } catch (Exception ex) { NLogger.LogError(ex); NLogger.LogText("Exit Execute method with Error"); } return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { NLogger.Initialize(); NLogger.LogText("Entered Execute method"); ConfigUtilities.LoadConfig(); LanguageHandler.Init(); uiapp = commandData.Application; doc = uiapp.ActiveUIDocument.Document; revElementHandler = new RevitElementsHandler(uiapp); revFilterHandler = new RevitFiltersHandler(); IList <Element> selectedElements = new List <Element>(); // Handle multi-element selection Selection sel = uiapp.ActiveUIDocument.Selection; try { NLogger.LogText("Performing selection in Revit"); var pickedrefs = sel.PickObjects(ObjectType.Element, "Please select an element"); NLogger.LogText("Selection performed in Revit"); foreach (var pickedref in pickedrefs) { selectedElements.Add(doc.GetElement(pickedref)); } // TODO: DETERMINE IF SAME FAMILY OR NOT // Handle selected elements info extraction var elStructureList = revElementHandler.ProcessElements(selectedElements); var filteredElStrList = revFilterHandler.FilterElements(elStructureList); // Extract all Revit Families for selected Revit elements var fileredElStrRevitFamilies = Utility.GetFamilyTypes(filteredElStrList); if (fileredElStrRevitFamilies.Count > 1) { //MessageBox.Show("Selected elements belong to more than one family. They have to be part of a unique family."); MessageBox.Show(LanguageHandler.GetString("msgBox_SelMultipleRevFam")); } else { var win = CheckOpened("Offsite Panel"); if (win != null) { //elementWindow = win; //elementWindow.Show(); //elementWindow.Focus(); win.Close(); } elementWindow = new OffsiteForm(selectedElements, uiapp, RevitElementSelectionMode.FromView); elementWindow.Show(); } NLogger.LogText("Exit Execute method with Success"); } catch (UIRelevantException ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { NLogger.LogError(ex); NLogger.LogText("Exit Execute method with Error"); } return(Result.Succeeded); }