A Form used to create a wall
Inheritance: System.Windows.Forms.Form
示例#1
0
        /// <summary>
        /// Create a wall, append a node to tree view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createWallbutton_Click(object sender, EventArgs e)
        {
            // a sub-transaction is not necessary in this case
            // it is used for illustration purposes only
            using (SubTransaction subTransaction = new SubTransaction(m_document))
            {
                // if not handled explicitly, the sub-transaction will be rolled back when leaving this block
                try
                {
                    if (subTransaction.Start() == TransactionStatus.Started)
                    {
                        using (CreateWallForm createWallForm = new CreateWallForm(m_commandData))
                        {
                            createWallForm.ShowDialog();
                            if (DialogResult.OK == createWallForm.DialogResult)
                            {
                                updateModel(true);  // immediately update the view to see the changes

                                if (subTransaction.Commit() == TransactionStatus.Committed)
                                {
                                    m_lastCreatedWall = createWallForm.CreatedWall;
                                    AddNode(OperationType.ObjectModification, "Created wall " + m_lastCreatedWall.Id.IntegerValue.ToString());
                                    UpdateButtonsStatus();
                                    return;
                                }
                            }
                            else
                            {
                                subTransaction.RollBack();
                                return;
                            }
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    TaskDialog.Show("Revit", "Exception when creating a wall: " + ex.Message);
                }
            }
            TaskDialog.Show("Revit", "Creating wall failed");
        }
示例#2
0
        /// <summary>
        /// Create a wall, append a node to tree view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createWallbutton_Click(object sender, EventArgs e)
        {
            // a sub-transaction is not necessary in this case
            // it is used for illustration purposes only
            using (SubTransaction subTransaction = new SubTransaction(m_document))
            {
               // if not handled explicitly, the sub-transaction will be rolled back when leaving this block
               try
               {
                  if (subTransaction.Start() == TransactionStatus.Started)
                  {
                     using (CreateWallForm createWallForm = new CreateWallForm(m_commandData))
                     {
                        createWallForm.ShowDialog();
                        if (DialogResult.OK == createWallForm.DialogResult)
                        {
                           updateModel(true);  // immediately update the view to see the changes

                           if (subTransaction.Commit() == TransactionStatus.Committed)
                           {
                              m_lastCreatedWall = createWallForm.CreatedWall;
                              AddNode(OperationType.ObjectModification, "Created wall " + m_lastCreatedWall.Id.IntegerValue.ToString());
                              UpdateButtonsStatus();
                              return;
                           }
                        }
                        else
                        {
                           subTransaction.RollBack();
                           return;
                        }
                     }
                  }
               }
               catch (System.Exception ex)
               {
                  MessageBox.Show("Exception when creating a wall: " + ex.Message);
               }
            }
            MessageBox.Show("Creating wall failed");
        }