private void bttnAreas_Click(object sender, RoutedEventArgs e) { try { selectedAnalysisBase = AnalysisBase.Rooms; ComboBoxItem selectedItem = cmbBoxTest.SelectedItem as ComboBoxItem; selectedLightingTest = (LightingTest)selectedItem.Tag; ComboBoxItem selectedView = cmbBoxView.SelectedItem as ComboBoxItem; selectedViewId = (ElementId)selectedView.Tag; this.DialogResult = true; } catch (Exception ex) { MessageBox.Show("Failed to select areas.\n" + ex.Message, "Select Areas", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public DwgExporter(UIApplication uiapp, LightingTest lightingTest, AnalysisBase analysisBase, ElementId viewId, List <Reference> references) { try { m_app = uiapp; m_doc = m_app.ActiveUIDocument.Document; selectedTest = lightingTest; selectedBase = analysisBase; selectedView = viewId; selectedReference = references; filePath = GetFilePath(); if (string.IsNullOrEmpty(filePath)) { MessageBox.Show("Please save the current Revit project before exporting.", "File Not Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { prefixes.Add("E-CAD", "E-CAD"); prefixes.Add("E-BIM", "E-BIM"); prefixes.Add("REVIT", "REVIT"); switch (selectedBase) { case AnalysisBase.Rooms: CreateViewsFromRooms(); break; case AnalysisBase.Areas: CreateViewsFromAreas(); break; } } } catch (Exception ex) { MessageBox.Show("Failed to export to dwg.\n" + ex.Message, "DWG Export", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; DwgExporterWindow exporterWindow = new DwgExporterWindow(m_app); if (exporterWindow.ShowDialog() == true) { LightingTest selectedTest = exporterWindow.SelectedLightingTest; AnalysisBase analysisBase = exporterWindow.SelectedAnalysisBase; ElementId viewId = exporterWindow.SelectedViewId; exporterWindow.Close(); List <Reference> selectedReference = new List <Reference>(); UIDocument uidoc = new UIDocument(m_doc); switch (analysisBase) { case AnalysisBase.Rooms: ISelectionFilter roomFilter = new RoomSelectionFilter(); selectedReference = uidoc.Selection.PickObjects(ObjectType.Element, roomFilter, "Select multiple rooms to create 3d views").ToList(); break; case AnalysisBase.Areas: ISelectionFilter areaFilter = new AreaSelectionFilter(); selectedReference = uidoc.Selection.PickObjects(ObjectType.Element, areaFilter, "Select multiple areas to create 3d views").ToList(); break; } DwgExporter exporter = new DwgExporter(m_app, selectedTest, analysisBase, viewId, selectedReference); if (exporter.ExportToDWG()) { MessageBox.Show("Rhino file has been successfully created!!\n" + exporter.RhinoFileName, "Rhino File Creation", MessageBoxButtons.OK, MessageBoxIcon.Information); } } return(Result.Succeeded); }