I've modified the code
/* * Created by SharpDevelop. * User: Mustafa * Date: 5/31/2016 * Time: 7:15 PM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.UI.Selection; using System.Collections.Generic; using System.Linq; using System.Drawing; using System.Windows.Forms; namespace myEditor { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.DB.Macros.AddInId("FA1AC762-0901-4B2B-B90B-803AC26177D6")] public partial class ThisDocument { private void Module_Startup(object sender, EventArgs e) { } private void Module_Shutdown(object sender, EventArgs e) { } #region Revit Macros generated code private void InternalStartup() { this.Startup += new System.EventHandler(Module_Startup); this.Shutdown += new System.EventHandler(Module_Shutdown); } #endregion public void myEditor() { Document doc = this.Document; Autodesk.Revit.DB.View pView = doc.ActiveView; Autodesk.Revit.DB.Transaction t = new Autodesk.Revit.DB.Transaction(this.Document, "Form"); t.Start(); try { // Create a new instance of the form. Form1 myForm = new Form1(); myForm.ShowDialog(); }// end try catch { TaskDialog.Show("Revit C# Error", "Error"); }// end catch t.Commit(); }// end myEditor } public partial class Form1 : System.Windows.Forms.Form { public Form1() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } void Form1Load(object sender, EventArgs e) { } void Button1Click(object sender, EventArgs e) { } void Button2Click(object sender, EventArgs e) { } void Button3Click(object sender, EventArgs e) { } } partial class Form1 { /// <summary> /// Designer variable used to keep track of non-visual components. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Disposes resources used by the form. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } /// <summary> /// This method is required for Windows Forms designer support. /// Do not change the method contents inside the source code editor. The Forms designer might /// not be able to load this method if it was changed manually. /// </summary> private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(62, 19); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = "ok"; this.button1.UseCompatibleTextRendering = true; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.Button1Click); // // button2 // this.button2.Location = new System.Drawing.Point(58, 83); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 1; this.button2.Text = "cancel"; this.button2.UseCompatibleTextRendering = true; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.Button2Click); // // button3 // this.button3.Location = new System.Drawing.Point(71, 169); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(75, 23); this.button3.TabIndex = 2; this.button3.Text = "apply"; this.button3.UseCompatibleTextRendering = true; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.Button3Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 262); this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1Load); this.ResumeLayout(false); } private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button1; } }
If it works like a charm the mark this reply as an answer.