Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prompt user to answer boolean choice using Revit API in C#

Tags:

c#

revit-api

I created a Revit plugin in C# that allow users totally new to 3D technology to choose a family, and insert it in their project. But right now the user does not have the choice between placing an object on the point anywhere or on a face. It's either one or the other. Right now my code looks like this :

bool useSimpleInsertionPoint = false; //or true
bool useFaceReference = true; //or false
if (useSimpleInsertionPoint)
{
//my code for insertion on point here
}
if (useFaceReference)
{
//my code for face insertion here
}

What I would like to do is ask the user what does he want to do. Does TaskDialog.Show would do the trick or is it something else ?

Thanks in advance.

like image 636
Jordi1302 Avatar asked Mar 16 '23 21:03

Jordi1302


1 Answers

Vincent's approach is good. The one thing that I like a little bit more is to use the CommandLink options with TaskDialog. This gives you the "big option" buttons to pick from, provides both an answer as well as an optional line of "explanation" about each answer.

The code looks like:

TaskDialog td = new TaskDialog("Decision");
td.MainContent = "What do you want to do?";
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
                   "Use Simple Insertion Point",
                   "This option works for free-floating items");
td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
                    "Use Face Reference",
                    "Use this option to place the family on a wall or other surface");

switch (td.Show())
 {
     case TaskDialogResult.CommandLink1:
        // do the simple stuff
        break;

     case TaskDialogResult.CommandLink2:
       // do the face reference
        break;

     default:
       // handle any other case.
        break;
 }
like image 146
Matt Avatar answered Apr 08 '23 23:04

Matt