public CommandForm(UIApplication uiapp, string bcf, INIDataManager iniManager) { try { m_app = uiapp; m_doc = uiapp.ActiveUIDocument.Document; bcfFile = bcf; iniDataManager = iniManager; bcfReader = new BCFReaderClass(bcfFile, iniDataManager); bcfFiles = bcfReader.BcfFiles; InitializeComponent(); this.Text = "HOK BCF Reader v." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); CollectViews(); DisplayIssues(); if (listViewIssue.Items.Count > 0) { listViewIssue.Items[0].Selected = true; } if (listViewStatus.Items.Count > 0) { listViewStatus.Items[0].Selected = true; } } catch (Exception ex) { MessageBox.Show("Failed to initialize CommandForm.\n" + ex.Message, "CommandForm", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void bttnToRoom_Click(object sender, EventArgs e) { massCategory = GetCategory(); iniDataManager = new INIDataManager(m_app, massCategory); defDictionary = new Dictionary <string, Definition>(); defDictionary = iniDataManager.DefDictionary; string parameters = ""; foreach (string param in defDictionary.Keys) { parameters += "[" + param + "] "; } bool result = false; switch (massCategory) { case MassCategory.Rooms: result = TransferToRoom(roomDictionary); break; case MassCategory.Areas: result = TransferToRoom(areaDictionary); break; case MassCategory.Floors: result = TransferToRoom(floorDictionary); break; } if (result) { DialogResult dr = MessageBox.Show("Parameters values have been successfully transferred from Mass to" + massCategory.ToString() + ".\n" + parameters, "Updated Parameters", MessageBoxButtons.OK, MessageBoxIcon.Information); if (dr == DialogResult.OK) { this.DialogResult = DialogResult.OK; } } }
Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { try { m_app = commandData.Application; m_doc = m_app.ActiveUIDocument.Document; iniDataManager = new INIDataManager(m_app); if (iniDataManager.FindINI()) { TaskDialog taskdialog = new TaskDialog("BCF Reader"); taskdialog.MainInstruction = "Open a BCF file."; taskdialog.MainContent = "Some bcf files have ever saved in this Revit project.\n You can open a new BCF file or choose a linked file on the file lists."; taskdialog.AllowCancellation = true; taskdialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Open a new BCF file."); taskdialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Select a linked BCF file."); iniDataManager.ReadINI();//collect reference data into referencedictionary TaskDialogResult tResult = taskdialog.Show(); if (TaskDialogResult.CommandLink1 == tResult) { bcfFile = OpenBCF(iniDataManager.MasterFilePath); } else if (TaskDialogResult.CommandLink2 == tResult) { BcfListForm bcfForm = new BcfListForm(); bcfForm.RefDictionary = iniDataManager.RefDictionary; bcfForm.DisplayBcfFiles(); if (DialogResult.OK == bcfForm.ShowDialog()) { bcfFile = bcfForm.BCFPath; } } iniDataManager.SelectedFilePath = bcfFile; if (File.Exists(bcfFile)) { commandForm = new CommandForm(m_app, bcfFile, iniDataManager); commandForm.ShowDialog(); } else if (bcfFile == null) { } else { MessageBox.Show("BCF file dose not exist.\n" + bcfFile, "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (null != iniDataManager.MasterFilePath) { bcfFile = OpenBCF(iniDataManager.MasterFilePath); iniDataManager.SelectedFilePath = bcfFile; if (null != bcfFile) { commandForm = new CommandForm(m_app, bcfFile, iniDataManager); commandForm.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show("This tool Cannot open the BCF file. Please select an appropriate file. \n" + ex.Message, "Failure: Opening BCF file", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(Result.Succeeded); }