- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I'm trying to create GUI that will gently guide Add-in users through a chain of commands. So far, I've found myself in a middle of nowhere.
I'm acknowledged of inavailability to execute commands outside RevitAPI context, and I've thought of a way of dealing with it. I've created one main implementation of IExternalCommand and incapsulated all of the logic into instances of Base_Routine class. I want user to set behaviour of the routine with the help of my GUI. Here's my code snippet
[Transaction(mode: TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
class Run : IExternalCommand
{
private Base_Routine RoutineBehaviour;
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
SetRoutineBehaviour();
RoutineBehaviour.ExecuteRoutine(commandData);
return Result.Succeeded;
}
private void SetRoutineBehaviour()
{
System.Windows.Forms.Form landing = new GUI.Landing();
if (landing.ShowDialog() == System.Windows.Forms.DialogResult.OK);
//Some code here that sets behaviour
}
GUI.Landing form is supposed to call for another Form after i click a button on it. However, another form doesn't open and a NullReferenceException is thrown. Right now I'm struggling to understand whether this approach will give any result (the reason behind that is my basic level of programming proficiency), so I have a couple of questions:
1. Is the generall approach correct? Or should I take a closer look at the IExternalEventHandler?
if (the approach is correct){
2. Should i create a separate thread for my forms-based GUI or is MTAthread by default enough? What should I do with them? How should I handle them? (I have basically no understanding on how threads work, so any help in this area is appreciated)
3. Are there any examples or related articles i should study? I've read a couple of them from https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28 but I don't fully understand if any of these solutions are suitable for what I'm trying to do
Much appreciation
Solved! Go to Solution.