- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have created an add-in to create documents/drawings. The creation of the documents has been tested and works. I have a Form with a few checkboxes to allow the selection of what file types are needed. The issue I am having is the first time I open Revit and run the add-in, everything functions correctly. However, when I try to use the add-in a second time in the session, the form opens, but on submit_click, nothing happens. The dialog closes and nothing happens. Any insight as to why it works the first time and not after that would be appreciated. Class and Form scripts can be found below. Sorry for the length of the scripts, I tried to remove all unnecessary items.
Class.cs
namespace ProjectPrintingOptions
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Document doc = uidoc.Document;
ProjectPrintForm Form1 = new ProjectPrintForm(commandData);
Form1.ShowDialog();
//Create ViewSet of sheets for printing/exporting
ViewSet mySheets = new ViewSet();
using (Transaction trans = new Transaction(doc))
{
try
{
trans.Start("Print PDFs");
//Code to set print settings and export settings
foreach (ViewSheet vv in mySheets)
{
//Code to print and export sheets as needed
}
trans.Commit();
}
catch (Exception e)
{
Debug.Print(e.Message);
trans.RollBack();
}
}
return Result.Succeeded;
}
}
}
Form.cs
namespace ProjectPrintingOptions
{
public partial class ProjectPrintForm : System.Windows.Forms.Form
{
private UIApplication uiapp;
private UIDocument uidoc;
private Autodesk.Revit.ApplicationServices.Application app;
private Document doc;
public ProjectPrintForm (ExternalCommandData commandData)
{
InitializeComponent();
uiapp = commandData.Application;
uidoc = uiapp.ActiveUIDocument;
app = uiapp.Application;
doc = uidoc.Document;
}
private void Box1checkbox_CheckedChanged(object sender, EventArgs e)
{
}
private void Box2checkbox_CheckedChanged(object sender, EventArgs e)
{
}
private void Box3checkbox_CheckedChanged(object sender, EventArgs e)
{
}
private void Box4checkbox_CheckedChanged(object sender, EventArgs e)
{
}
public bool Box1Test
{
get { return Box1checkbox.Checked; }
set { Box1checkbox.Checked = value; }
}
public bool Box2Test
{
get { return Box2checkbox.Checked; }
set { Box2checkbox.Checked = value; }
}
public bool Box3Test
{
get { return Box3checkbox.Checked; }
set { Box3checkbox.Checked = value; }
}
public bool Box4Test
{
get { return Box4checkbox.Checked; }
set { Box4checkbox.Checked = value; }
}
private void cancelButton_Click(object sender, EventArgs e)
{
cancelButton.DialogResult = DialogResult.Cancel;
}
private void submitButton_Click(object sender, EventArgs e)
{
submitButton.DialogResult = DialogResult.OK;
Close();
return;
}
}
}
Solved! Go to Solution.