C# Addin form, Reset the form when show

C# Addin form, Reset the form when show

Anonymous
Not applicable
3,996 Views
19 Replies
Message 1 of 20

C# Addin form, Reset the form when show

Anonymous
Not applicable

Hi, recently i created a new add-in for my Revit.

I followed the Autodesk tutorial to make it (Create class in virtual studio etc..)

My program have to show a Form like the first screenshot.

As we can see, the Form is blank and it's totally normal. But, when i close it and open it again, it conserve previous information (screenshot 2) while i wrote this in virtual studio :

 

comboBox1.Items.Clear();
comboBox2.Items.Clear();
comboBox3.Items.Clear();
listBox1.Items.Clear();
comboBox1.ResetText();
comboBox2.ResetText();
comboBox3.ResetText();

 

You can see the context in screenshot 3.

Screenshot 1Screenshot 1Screenshot 2Screenshot 2Screenshot 3Screenshot 3

 

0 Likes
Accepted solutions (1)
3,997 Views
19 Replies
Replies (19)
Message 2 of 20

TripleM-Dev.net
Advisor
Advisor

Hi,

 

Are you re-using the form instance variable?, how do you call and create the form itself.

The initializer is only called if the form is created, put the "Resets" in the Form Shown event.

 

- Michel

 

0 Likes
Message 3 of 20

Anonymous
Not applicable

I basically use this tutorial (https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/simplecontent/content/lesso...) but removed all the example code and, inside the Class in Virtual studio, i create Form that is called by this function :

 

 

 

 

 

And then, i can use my form.

 

"The initializer is only called if the form is created, put the "Resets" in the Form Shown event."

That what i exactly want to do but don't know how.

0 Likes
Message 4 of 20

jeremytammik
Autodesk
Autodesk

Dear Thomas,

 

Thank you for your query.

 

If you display your form using ShowDialog, it becomes a modal form and you should have no problems whatsoever.

 

If you instead display your form using Show, it becomes a modeless form and things get more complicated.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 20

Anonymous
Not applicable

Thank for your reply.

 

I already use ShowDialog when I start my plug-in as you can see.

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)

        {

            //Get application and documnet objects

            UIApplication uiapp = commandData.Application;

            Document doc = uiapp.ActiveUIDocument.Document;

            application = commandData.Application;
            document = application.ActiveUIDocument.Document;
            uiDocument = application.ActiveUIDocument;
                        
			boite.ShowDialog();
            


			return Result.Succeeded;

        }

When i click the first time on Addins > External Tools > MyPluginName the Form start correctly and my variables are correctly clean (logic) but when I close it with the red cross and start it again (same method) it memorized all files path and my choices.

 

I tried different way to put my initializing code but none of them work.

0 Likes
Message 6 of 20

TripleM-Dev.net
Advisor
Advisor

Yes and where does the object "boite" come from, where do you initialize "boite"?

If it's never released, the object will be reused.

 

Otherwise call in the form's onshown event to reset the values.

Form.Shown Event 

 

- Michel

Message 7 of 20

Anonymous
Not applicable

Hi,

This is the code how is generated by virtual studio for a Form

In "MyFormName.cs" we have :

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Import_Selected_DET
{
    public partial class Interface_LIB : Form
    {
        //My Var
        public Interface_LIB()
        {
            InitializeComponent();

            
        }

 

In "MyFormName.Designer.cs" we have :

 

namespace Import_Selected_DET
{
    partial class Interface_LIB
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Interface_LIB));
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.ListeFAB = new System.Windows.Forms.ComboBox();
            this.ListeGAM = new System.Windows.Forms.ComboBox();
            this.ListeREP = new System.Windows.Forms.ComboBox();
            this.ListDET = new System.Windows.Forms.ListBox();
            this.btnImport = new System.Windows.Forms.Button();
            this.btnBiblio = new System.Windows.Forms.Button();
            this.btnClose = new System.Windows.Forms.Button();
            this.btnImportPlace = new System.Windows.Forms.Button();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.txtRecherche = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.btnStart = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("Century", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(6, 16);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(185, 23);
            this.label1.TabIndex = 0;
            this.label1.Text = "Choix du fabricant :";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("Century", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.Location = new System.Drawing.Point(6, 121);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(190, 23);
            this.label2.TabIndex = 1;
            this.label2.Text = "Choix de la gamme :";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("Century", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.Location = new System.Drawing.Point(6, 230);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(193, 23);
            this.label3.TabIndex = 2;
            this.label3.Text = "Choix du répertoire :";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Font = new System.Drawing.Font("Century", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.Location = new System.Drawing.Point(282, 16);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(267, 23);
            this.label4.TabIndex = 3;
            this.label4.Text = "Choix de l\'élément de détail :";
            // 
            // ListeFAB
            // 
            this.ListeFAB.Font = new System.Drawing.Font("Century", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ListeFAB.FormattingEnabled = true;
            this.ListeFAB.Location = new System.Drawing.Point(5, 51);
            this.ListeFAB.Name = "ListeFAB";
            this.ListeFAB.Size = new System.Drawing.Size(186, 23);
            this.ListeFAB.TabIndex = 4;
            this.ListeFAB.SelectedIndexChanged += new System.EventHandler(this.ListeFAB_SelectedIndexChanged);
            // 
            // ListeGAM
            // 
            this.ListeGAM.Font = new System.Drawing.Font("Century", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ListeGAM.FormattingEnabled = true;
            this.ListeGAM.Location = new System.Drawing.Point(6, 156);
            this.ListeGAM.Name = "ListeGAM";
            this.ListeGAM.Size = new System.Drawing.Size(186, 23);
            this.ListeGAM.TabIndex = 5;
            this.ListeGAM.SelectedIndexChanged += new System.EventHandler(this.ListeGAM_SelectedIndexChanged);
            // 
            // ListeREP
            // 
            this.ListeREP.Font = new System.Drawing.Font("Century", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ListeREP.FormattingEnabled = true;
            this.ListeREP.Location = new System.Drawing.Point(5, 265);
            this.ListeREP.Name = "ListeREP";
            this.ListeREP.Size = new System.Drawing.Size(186, 23);
            this.ListeREP.TabIndex = 6;
            this.ListeREP.SelectedIndexChanged += new System.EventHandler(this.ListeREP_SelectedIndexChanged);
            // 
            // ListDET
            // 
            this.ListDET.FormattingEnabled = true;
            this.ListDET.Location = new System.Drawing.Point(286, 81);
            this.ListDET.Name = "ListDET";
            this.ListDET.Size = new System.Drawing.Size(397, 433);
            this.ListDET.TabIndex = 7;
            this.ListDET.SelectedIndexChanged += new System.EventHandler(this.ListDET_SelectedIndexChanged);
            // 
            // btnImport
            // 
            this.btnImport.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.btnImport.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.btnImport.ForeColor = System.Drawing.SystemColors.HotTrack;
            this.btnImport.Location = new System.Drawing.Point(6, 420);
            this.btnImport.Name = "btnImport";
            this.btnImport.Size = new System.Drawing.Size(186, 44);
            this.btnImport.TabIndex = 8;
            this.btnImport.Text = "Importer";
            this.btnImport.UseVisualStyleBackColor = false;
            this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
            // 
            // btnBiblio
            // 
            this.btnBiblio.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.btnBiblio.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.btnBiblio.ForeColor = System.Drawing.SystemColors.HotTrack;
            this.btnBiblio.Location = new System.Drawing.Point(218, 12);
            this.btnBiblio.Name = "btnBiblio";
            this.btnBiblio.Size = new System.Drawing.Size(279, 23);
            this.btnBiblio.TabIndex = 9;
            this.btnBiblio.Text = "Changer emplacement bibliothèque";
            this.btnBiblio.UseVisualStyleBackColor = false;
            this.btnBiblio.Click += new System.EventHandler(this.btnBiblio_Click);
            // 
            // btnClose
            // 
            this.btnClose.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.btnClose.Font = new System.Drawing.Font("Century", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnClose.ForeColor = System.Drawing.Color.Red;
            this.btnClose.Location = new System.Drawing.Point(503, 12);
            this.btnClose.Name = "btnClose";
            this.btnClose.Size = new System.Drawing.Size(200, 23);
            this.btnClose.TabIndex = 11;
            this.btnClose.Text = "Close Plug-in";
            this.btnClose.UseVisualStyleBackColor = false;
            this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
            // 
            // btnImportPlace
            // 
            this.btnImportPlace.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.btnImportPlace.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.btnImportPlace.ForeColor = System.Drawing.SystemColors.HotTrack;
            this.btnImportPlace.Location = new System.Drawing.Point(6, 470);
            this.btnImportPlace.Name = "btnImportPlace";
            this.btnImportPlace.Size = new System.Drawing.Size(186, 44);
            this.btnImportPlace.TabIndex = 12;
            this.btnImportPlace.Text = "Importer et placer";
            this.btnImportPlace.UseVisualStyleBackColor = false;
            this.btnImportPlace.Click += new System.EventHandler(this.btnImportPlace_Click);
            // 
            // groupBox1
            // 
            this.groupBox1.BackColor = System.Drawing.SystemColors.Control;
            this.groupBox1.Controls.Add(this.label5);
            this.groupBox1.Controls.Add(this.txtRecherche);
            this.groupBox1.Controls.Add(this.btnImportPlace);
            this.groupBox1.Controls.Add(this.ListDET);
            this.groupBox1.Controls.Add(this.label4);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.btnImport);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.ListeREP);
            this.groupBox1.Controls.Add(this.ListeFAB);
            this.groupBox1.Controls.Add(this.ListeGAM);
            this.groupBox1.Location = new System.Drawing.Point(12, 52);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(689, 529);
            this.groupBox1.TabIndex = 13;
            this.groupBox1.TabStop = false;
            // 
            // txtRecherche
            // 
            this.txtRecherche.Location = new System.Drawing.Point(357, 49);
            this.txtRecherche.Name = "txtRecherche";
            this.txtRecherche.Size = new System.Drawing.Size(326, 20);
            this.txtRecherche.TabIndex = 13;
            this.txtRecherche.TextChanged += new System.EventHandler(this.txtRecherche_TextChanged);
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Font = new System.Drawing.Font("Century", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.Location = new System.Drawing.Point(283, 51);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(68, 15);
            this.label5.TabIndex = 14;
            this.label5.Text = "Recherche :";
            // 
            // btnStart
            // 
            this.btnStart.BackColor = System.Drawing.SystemColors.ControlLightLight;
            this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.btnStart.Font = new System.Drawing.Font("Century", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnStart.ForeColor = System.Drawing.Color.Green;
            this.btnStart.Location = new System.Drawing.Point(12, 12);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(200, 23);
            this.btnStart.TabIndex = 14;
            this.btnStart.Text = "Start Plug-in";
            this.btnStart.UseVisualStyleBackColor = false;
            this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
            // 
            // Interface_LIB
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(715, 593);
            this.Controls.Add(this.btnStart);
            this.Controls.Add(this.btnClose);
            this.Controls.Add(this.btnBiblio);
            this.Controls.Add(this.groupBox1);
            this.Cursor = System.Windows.Forms.Cursors.Default;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "Interface_LIB";
            this.Text = "Let it BIM - Selection d\'éléments de détail";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.ComboBox ListeFAB;
        private System.Windows.Forms.ComboBox ListeGAM;
        private System.Windows.Forms.ComboBox ListeREP;
        private System.Windows.Forms.ListBox ListDET;
        private System.Windows.Forms.Button btnImport;
        private System.Windows.Forms.Button btnBiblio;
        private System.Windows.Forms.Button btnClose;
        private System.Windows.Forms.Button btnImportPlace;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox txtRecherche;
        private System.Windows.Forms.Button btnStart;
    }
}

And then, you already see the code to start Addin.

For more information, My Form is called "Interface_LIB" and the Program in virtual studio is "Import_Selected_DET".

 

0 Likes
Message 8 of 20

jeremytammik
Autodesk
Autodesk

Dear Thomas,

 

I do not see any of the Revit API calls that I presume you are using to populate your form data.

 

Where are they?

 

I would suggest that you take a look at an existing, working Windows form and examine how it interacts with and is populated by the Revit API calls that it interacts with.

 

There are sooo many beautiful working examples out there.

 

Start from a minimal working example and add your own code to that.

 

Here is my favourite implementation that shows how you can cleanly separate the Windows API from the Revit API stuff:

 

https://thebuildingcoder.typepad.com/blog/2012/05/the-schedule-api-and-access-to-schedule-data.html

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 9 of 20

TripleM-Dev.net
Advisor
Advisor

Yes that's the Form Class, but nowhere it's instanced!.

How do you set the variable "boite"

 

- Michel

0 Likes
Message 10 of 20

Anonymous
Not applicable

Hi, this is the full code in my Class

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System.IO;
using Autodesk.Revit.DB.Events;

namespace Import_Selected_DET

{

    [Transaction(TransactionMode.Manual)]

    [Regeneration(RegenerationOption.Manual)]

    public class Class_Import_Selected_DET : IExternalCommand

    {
        public static Document document;
        public static Interface_LIB boite = new Interface_LIB();
        public static UIApplication application;
        public static UIDocument uiDocument;

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)

        {

            //Get application and documnet objects

            UIApplication uiapp = commandData.Application;

            Document doc = uiapp.ActiveUIDocument.Document;

            application = commandData.Application;
            document = application.ActiveUIDocument.Document;
            uiDocument = application.ActiveUIDocument;
                        
			boite.ShowDialog();
            


			return Result.Succeeded;

        }

        public static void InsererFamille(string chemin)
        {
            
            using (Transaction tr = new Transaction(document, "Importer la famille"))
            {

                tr.Start();
                document.LoadFamily(chemin);
                tr.Commit();

                if (tr.HasEnded()) { TaskDialog.Show("titre", "Transaction finie"); }
            }

        }

        public static void PlacerFamille(string nomFamille)
        {
                        
            
            FilteredElementCollector familyCollector = new FilteredElementCollector(document);
            familyCollector.OfClass(typeof(FamilySymbol));
            FamilySymbol familySymbolToFind = null;
            

            foreach (FamilySymbol familySymbol in familyCollector)
            {
                //To search by FamilySymbol name
                //TaskDialog.Show("Revit", familySymbol.Name.ToString());
                if (familySymbol.Name == nomFamille) 
                {
                    familySymbolToFind = familySymbol;
                    TaskDialog.Show("Revit", familySymbol.Family.Name.ToString());
                } 
                //To search by Family name
                else if (familySymbol.Family.Name == nomFamille) 
                {
                    familySymbolToFind = familySymbol;
                    TaskDialog.Show("Revit", familySymbol.Family.Name.ToString());
                }

            }

            

            try
            {
                uiDocument.PromptForFamilyInstancePlacement(familySymbolToFind);
            }
            catch { TaskDialog.Show("titre", "Erreur de placement"); }
            

            
        }

        public static List<string> RFAFilter (string chemin,bool retournechemin)
        {
            List<string> fichiers = new List<string>();
            DirectoryInfo dir = new DirectoryInfo(chemin);
            FileInfo[] fichier = dir.GetFiles();

            if (fichier.Length == 0) { return fichiers; }
            else
            {
                foreach(FileInfo file in fichier)
                {
                    if(retournechemin)
                    {
                        string nomFile = file.FullName;
                        bool contient = nomFile.Contains(".rfa");
                        if (contient)
                        {
                            fichiers.Add(nomFile);
                        }
                    }
                    else
                    {
                        string nomFile = file.Name;
                        bool contient = nomFile.Contains(".rfa");
                        if (contient)
                        {
                            fichiers.Add(nomFile);
                        }
                    }
                    
                }
                return fichiers;
            }

        }
        


    }

}
0 Likes
Message 11 of 20

Anonymous
Not applicable

By the way,

my uiDocument.PromptForFamilyInstancePlacement(familySymbolToFind) doesn't work too.

but it's an other subject ..

0 Likes
Message 12 of 20

jeremytammik
Autodesk
Autodesk

Dear Thomas,

 

I see you raised the same question on StackOverflow too:

 

https://stackoverflow.com/questions/61318675/revit-addin-reset-all-values-of-forms-when-start

 

Adrian answered you there, saying, Are you closing the window or just hiding it? Make sure that you destroy the window object when you close it – Adrian Efford 23 hours ago.

 

Just as he says, if you destroy the window all its data will disappear.

 

When you recreate it, you have to add new data.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 13 of 20

TripleM-Dev.net
Advisor
Advisor

First i would put the instancing of "boite" in the execute method, like with document.

 

public static Interface_LIB boite = new Interface_LIB();

 change to:

public static Interface_LIB boite;

// and in execute:
boite = new Interface_LIB();

 

And then?? How is "InsererFamille" or "PlacerFamille" called?

The form ends after "boite.ShowDialog();" and I see no event caller for the methods above.

So is right the form only shows and that's it?

 

Ps. Would maybe even place Form in Using block.

 

- Michel

0 Likes
Message 14 of 20

Anonymous
Not applicable

HI,

To reply jeremytammik

 

Thank, I hadn't seen it, of course i can destroy the Window but, the form doesn't do it itself when you click on the red cross ?

I mean, When user click on it, why the form is not destroy ? And where have I to put the destruction of the Form for that execute with a red cross click.

 

To reply you TripleM-Dev

I use there's function in code in Form. But i don't show it because it's not necessary.

 

No, the form show and then, i use button, listBox etc..

 

0 Likes
Message 15 of 20

corinne.astori
Advocate
Advocate

@AnonymousThis is how I do it with using statement (see image). But you can also look at some examples like SDK sample: AllViews.ScreenshotScreenshot

0 Likes
Message 16 of 20

Anonymous
Not applicable

That's where my knowledge stop, i don't understand what you done.

 

And I don't know what is SDK sample.

0 Likes
Message 17 of 20

Anonymous
Not applicable
Accepted solution

Ok. I find a solution !

 

I create a new definition that is called "DestructionMassive". I put all the code i use to reset my form in it.

Like this :

 

public MyFormName (Autodesk.Revit.UI.ExternalCommandData commandData)
        {
            InitializeComponent();

        }

public void DestructionMassiveRevit()
        {
            //my code
        }

 

Then I go to MyClassName.cs (in public class MyClassName : IExternalCommand) and made this :

 

//set my var
public static MyFormName boite = new MyFormName(null);


public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)

        {

            //Get application and documnet objects

            UIApplication uiapp = commandData.Application;

            Document doc = uiapp.ActiveUIDocument.Document;

            application = commandData.Application;
            document = application.ActiveUIDocument.Document;
            uiDocument = application.ActiveUIDocument;

            
            boite.DestructionMassive();
            boite.ShowDialog();
       }

 

When i start my Addin, it automatically reset all my control and then, it show the form.

 

Thank you very much @corinne.astori @TripleM-Dev.net  @jeremytammik 

 

0 Likes
Message 18 of 20

jeremytammik
Autodesk
Autodesk

Dear Thomas,

 

Congratulations on solving it!

 

However, if you do not know what I mean by Revit SDK sample, please do nothing else for now until you have worked through the getting started material and installed both the Revit SDK and RevitLookup:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

That will save both you and the rest of the universe a ton of head-scratching trying to answer questions that have already been answered hundreds of times over in the past.

 

Thank you!

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 19 of 20

Anonymous
Not applicable

@jeremytammik 

 

Thank for information, I read it and don't understand who to install many of the stuff you describe.

Maybe we can continue our discussion on linkedIn or maybe not.

 

Thank. Thomas Lecuppre

0 Likes
Message 20 of 20

jeremytammik
Autodesk
Autodesk

Dear Thomas,

 

The installation of all the "stuff" has been described dozens of times in the past by The Building Coder.

 

I cannot describe it any better for you than I already have for the community in general.

 

My job is done. I have described.

 

Your job is to read and learn and understand.

 

Good luck and have fun completing your part of the contract!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder