Revit API / WIndows Forms / IExternal Commands

Anonymous

Revit API / WIndows Forms / IExternal Commands

Anonymous
Not applicable

Hello,

 

Has anyone has success implementing forms into an external command to be read and implemented into a ribbon application?  I have the ribbon features, but am having issues between the external command and windows forms.  Please see the code below... Any help would be greatly appreciated!!! Thank you.

 

using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.Architecture;
using System.IO;
using System.Windows.Media.Imaging;


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;

namespace Project_Button
{

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();


}

private void saveFD_FileOk(object sender, CancelEventArgs e)
{
}
private void openFD_FileOk(object sender, CancelEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
saveFD.InitialDirectory = ("C:");
saveFD.Title = "Save Project Template";
saveFD.Filter = "Text Files(*.txt)|*.txt";
saveFD.Filter = "Text Files|*.txt|Word Files|*.doc";
saveFD.ShowDialog();
}

private void button3_Click(object sender, EventArgs e)
{
openFD.InitialDirectory = ("C:");
openFD.Title = "Open Project Template";
openFD.Filter = "Text Files(*.txt)|*.txt";
openFD.Filter = "Text Files|*.txt|Word Files|*.doc";
openFD.ShowDialog();
}

}

}

 

When I tried adding the external command lines as follows, my entire form became corrupt...

 

[Transaction(TransactionMode.Automatic)]
[Regeneration(RegenerationOption.Manual)]
public class ProjectButton : IExternalCommand

{
public Result Execute(
Autodesk.Revit.UI.ExternalCommandData commandData,
ref string message,
Autodesk.Revit.DB.ElementSet elements)
{
}

 

THANKS AGAIN GUYS!!!

0 Likes
Reply
1,409 Views
1 Reply
Reply (1)

arnostlobel
Alumni
Alumni

As far as I can tell (by counting curly brackets) your ProjectButton class is outside of the Project_Button namespace which encompasses the Form class. It is unlikely then that the external command just by sheer existence would affect the form in any way. What do you mean when you say that "form became corrupt"? I would expect problem more from possible clash of namespace you are "using" in you application. I wonder if it is possible that the compiler would not give you a warning about such a clash, perhaps, and linked your dialog with mixed up classes taken from some of the Autodesk.Revit namespace-dom. That is just a wild theory, hhoever. Maybe when we get more details about the "corrupted form" we'll be able to theoretize more.

Arnošt Löbel
0 Likes