/// <summary> /// initialize the UI ComboBox's appearance /// </summary> /// <param name="sender">object who sent this event</param> /// <param name="e">event args</param> private void TrussForm_Load(object sender, EventArgs e) { this.TrussTypeComboBox.SelectedIndex = 0; this.ViewComboBox.SelectedIndex = 0; //user pre-select a truss in Revit UI if (m_truss != null) { // show the truss type and level of pre-selected truss in the ComboBox String nameOfTrussType = m_truss.TrussType.get_Parameter (BuiltInParameter.SYMBOL_FAMILY_AND_TYPE_NAMES_PARAM).AsString(); this.TrussTypeComboBox.SelectedIndex = this.TrussTypeComboBox.Items.IndexOf(nameOfTrussType); Parameter viewName = m_truss.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM); if (null == viewName || 0 == viewName.AsString().CompareTo(NoAssociatedLevel)) { this.ViewComboBox.Items.Add(NoAssociatedLevel); this.ViewComboBox.SelectedIndex = this.ViewComboBox.Items.IndexOf(NoAssociatedLevel); } else { String nameOfViewPlane = viewName.AsString().Substring(8); this.ViewComboBox.SelectedIndex = this.ViewComboBox.Items.IndexOf(nameOfViewPlane); } this.TrussTypeComboBox.Enabled = false; this.CreateButton.Enabled = false; this.ViewComboBox.Enabled = false; trussGeometry = new TrussGeometry(m_truss, m_commandData); this.TrussGraphicsTabControl.SelectedIndex = 1; } }
/// <summary> /// create new truss /// </summary> /// <param name="sender">object who sent this event</param> /// <param name="e">event args</param> private void CreateButton_Click(object sender, EventArgs e) { try { Transaction transaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "CreateTruss"); transaction.Start(); // create the truss m_truss = CreateTruss(); m_truss.Location.Move(new Autodesk.Revit.DB.XYZ(0, 0, m_selectedView.GenLevel.Elevation)); transaction.Commit(); trussGeometry = new TrussGeometry(m_truss, m_commandData); this.TrussGraphicsTabControl.SelectedIndex = 1; } catch (Exception ex) { MessageBox.Show(ex.Message); } this.TrussTypeComboBox.Enabled = false; this.CreateButton.Enabled = false; this.ViewComboBox.Enabled = false; }
/// <summary> /// create new truss /// </summary> /// <param name="sender">object who sent this event</param> /// <param name="e">event args</param> private void CreateButton_Click(object sender, EventArgs e) { try { Transaction transaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "CreateTruss"); transaction.Start(); // create the truss m_truss = CreateTruss(); m_truss.Location.Move(new Autodesk.Revit.DB.XYZ (0, 0, m_selectedView.GenLevel.Elevation)); transaction.Commit(); trussGeometry = new TrussGeometry(m_truss, m_commandData); this.TrussGraphicsTabControl.SelectedIndex = 1; } catch (Exception ex) { MessageBox.Show(ex.Message); } this.TrussTypeComboBox.Enabled = false; this.CreateButton.Enabled = false; this.ViewComboBox.Enabled = false; }