Dear Jeremy
Thanks so much for your fast reply, much appreciated.
I've gone through it for a couple of hours but not quite sure where I'm making the mistake.
Solution name: ImportDatafromForm
Form name: FormIndependent
Class name that calls the form:RunForm
When I press the button in the ribbon I get the error message: Failed to initialize the add-in"Open form" because the class "ImportDatafromForm.RunForm" cannot be found in the add-inn assembly.
The FullClassName provides the entry point for Revit to call the add-in application.For Revit to run the add-in, you must ensure this class implements the "Autodesk.Revit.UI.IExternalCommand" Interface.
However in the adding I've included the class
<AddIn Type="Command">
<Name>ImportDatafromForm</Name>
<Assembly>ImportDatafromForm.dll</Assembly>
<AddInId>5493CF3C-C25D-41EB-B933-F0876E0D3819</AddInId>
<FullClassName>ImportDatafromForm.RunForm</FullClassName>
<Text>runs the form</Text>
<Description>Calls the form to run it</Description>
<VendorId>Test</VendorId>
<VendorDescription>Test</VendorDescription>
<VisibilityMode>NotVisibleWhenNoActiveDocument</VisibilityMode>
</AddIn>
And the Form
<AddIn Type="Command">
<Name>ImportDatafromForm</Name>
<Assembly>ImportDatafromForm.dll</Assembly>
<AddInId>A210D299-D826-4CB2-8E48-D42F200AE43C</AddInId>
<FullClassName>ImportDatafromForm.FormIndependent</FullClassName>
<Text>Form</Text>
<Description>Collects data in a form</Description>
<VendorId>Test</VendorId>
<VendorDescription>Test</VendorDescription>
<VisibilityMode>NotVisibleWhenNoActiveDocument</VisibilityMode>
</AddIn>
PushButtonData button6 = new PushButtonData("Button6", "calls the form", path, "ImportDatafromForm.RunForm");
Who should call the form RunForm:
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 ImportDatafromForm.Commands
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class RunForm : IExternalCommand
{
public static Document document;
public static FormIndependent FormData = new FormIndependent();
public static UIApplication application;
public static UIDocument uiDocument;
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
Document doc = uiapp.ActiveUIDocument.Document;
application = commandData.Application;
document = application.ActiveUIDocument.Document;
uiDocument = application.ActiveUIDocument;
FormData.ShowDialog();
return Result.Succeeded;
}
}
}
That should open the form FormIndependent:
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 ImportDatafromForm.Commands
{
public partial class FormIndependent : Form
{
public FormIndependent()
{
InitializeComponent();
}
}
}