Journaling m_dataBuffer; // A reference of Journaling. // Methods /// <summary> /// Constructor of JournalingForm /// </summary> /// <param name="dataBuffer">A reference of Journaling class</param> public JournalingForm(Journaling dataBuffer) { // Required for Windows Form Designer support InitializeComponent(); //Get a reference of ModelLines m_dataBuffer = dataBuffer; // Bind the data source of the typeComboBox and levelComboBox typeComboBox.DataSource = m_dataBuffer.WallTypes; typeComboBox.DisplayMember = "Name"; levelComboBox.DataSource = m_dataBuffer.Levels; levelComboBox.DisplayMember = "Name"; }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, ElementSet elements) { try { Transaction tran = new Transaction(commandData.Application.ActiveUIDocument.Document, "Journaling"); tran.Start(); // Create a real operate class Journaling deal = new Journaling(commandData); deal.Run(); // The main deal operation tran.Commit(); // if everything goes well, return succeeded. return(Autodesk.Revit.UI.Result.Succeeded); } catch (Exception ex) { // If there is something wrong, give error information and return failed message = ex.Message; return(Autodesk.Revit.UI.Result.Failed); } }