public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Carbo Life Project File (*.clcx)|*.clcx|All files (*.*)|*.*"; var path = openFileDialog.ShowDialog(); if (openFileDialog.FileName != "") { CarboRevitImportSettings importSettings = new CarboRevitImportSettings(); importSettings = importSettings.DeSerializeXML(); //Import the Files CarboLifeRevitImport.ImportElements(app, importSettings, openFileDialog.FileName); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; CarboRevitImportSettings importSettings = new CarboRevitImportSettings(); importSettings = importSettings.DeSerializeXML(); CarboLifeRevitImport.ImportElements(app, importSettings); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; string MyAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location; string MyAssemblyDir = Path.GetDirectoryName(MyAssemblyPath); CarboProject myProject = new CarboProject(); ICollection <ElementId> selectionList = uidoc.Selection.GetElementIds(); //Get levels List <CarboLevel> levellist = new List <CarboLevel>(); List <Level> levels = new FilteredElementCollector(doc).OfClass(typeof(Level)).Cast <Level>().OrderBy(l => l.Elevation).ToList(); foreach (Level lvl in levels) { CarboLevel newlvl = new CarboLevel(); newlvl.Id = lvl.Id.IntegerValue; newlvl.Name = lvl.Name; newlvl.Level = (lvl.Elevation * 304.8); levellist.Add(newlvl); } myProject.carboLevelList = levellist; //Get Settings ImportSettingsWindow importGroupWindow = new ImportSettingsWindow(levellist); importGroupWindow.ShowDialog(); CarboRevitImportSettings importsettings = importGroupWindow.importSettings; if (importGroupWindow.dialogOk == System.Windows.MessageBoxResult.Yes) { //Import the elements } else { return(Result.Succeeded); } //Launch normal Command CarboLifeRevitImport.ImportElements(app, importsettings, ""); return(Result.Succeeded); }