Radio Button Result to Start Right Routine

Radio Button Result to Start Right Routine

Anonymous
Not applicable
977 Views
6 Replies
Message 1 of 7

Radio Button Result to Start Right Routine

Anonymous
Not applicable

I have a dialog box (windows form) that has (2) two radio button groups which contain (3) three radio button options each.  What I am trying to do is start the right routine based on the value of ValueSelected1 as shown in the code below.  I just dont know how to invoke the command once the value is set.  Any help would be appreciated.

 

private void OK_Button_Click(object sender, EventArgs e)
        {
            string value1 = "";
            string value2 = "";

            if (All_Pipe_RadioButton.Checked)
            {
                value1 = All_Pipe_RadioButton.Text;
            }

            else if (Multiple_Pipe_RadioButton.Checked)
            {
                value1 = Multiple_Pipe_RadioButton.Text;
            }

            else if (Single_Pipe_RadioButton.Checked)
            {
                value1 = Single_Pipe_RadioButton.Text;
            }

            if (Ten_Feet_RadioButton.Checked)
            {
                value2 = Ten_Feet_RadioButton.Text;
            }

            else if (TwentyOne_Feet_RadioButton.Checked)
            {
                value2 = TwentyOne_Feet_RadioButton.Text;
            }

            else if (User_Feet_RadioButton.Checked)
            {
                value2 = User_Feet_TextBox.Text;
            }


            string ValueSelected1 = value1;
            string ValueSelected2 = value2;

            string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"/XYZ Tools/Log Files/Radio Button Selection.txt";


            using (StreamWriter writer = new StreamWriter(path, false))
            {
                writer.WriteLine(ValueSelected1 + "," + ValueSelected2);
            }

        }
0 Likes
Accepted solutions (2)
978 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

Dear lester.grace,

 

Does this have anything whatsoever to do with the Revit API?

 

What, please?

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 7

Anonymous
Not applicable

Jeremy:

 

Actually it does.  I am creating a windows form with Radio Buttons that when one is selected it evaluates which sub routine will be executed upon hitting the OK Button.  Another source said I need to define the variable outside of the OK Button so it can be used in the main program.

 

Sincerely

 

Lester

0 Likes
Message 4 of 7

jeremytammik
Autodesk
Autodesk

Dear Lester,

 

Sorry for being obtuse, but I still do not see the connection to the Revit API in any manner at all.

 

Would you like to explain further?

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 7

Anonymous
Not applicable

Jeremy:

 

I am writing a Revit application that has an initial interface using a windows form.  Once the appropriate radio buttons are selected on the windows form (aka Dialog Box) and the user presses the OK Button I want the appropriate sub routine of the main application to execute.  In the code provided I am using if statements to determine what radio button was selected and based on a value I have set to that radio button that would be the sub routine I would like to have executed.  Hope this clears things up.

 

Lester

0 Likes
Message 6 of 7

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Lester,

 

When you say 'subroutine', do you actually mean 'external command'?

 

If not, I would suggest that you do in fact implement a separate external command for each of the subroutines.

 

I would also suggest testing them individually first, before you research how to trigger them in a different way.

 

Furthermore, if you want to trigger an external command from your windows form, your windows form will have to be modeless, if it was opened by a Revit add-in. Alternatively, it might have been opened by an external application.

 

In both cases, you are basically attempting to drive Revit from outside, which is not possible per se.

 

There are workarounds to achieve this anyway.

 

The recommended approach is by using external events.

 

This is illustrated by the Revit SDK ModelessDialog samples ModelessForm_ExternalEvent, and ModelessForm_IdlingEvent, using the Idling event.

 

Before you do any further programming, take some time to read and understand the resasons why to and issues around using these events in depth.

 

It will pay off!

 

Here are lots of pointers on this:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28

 

Have fun exploring, and good luck!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 7

Dale.Bartlett
Collaborator
Collaborator
Accepted solution

To the best of my knowledge you won't be able to call a command, in a similar way that you might in AutoCAD.

 

Firstly create a command that is called from the Ribbon:

[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]

[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]

[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]

public class DoSomeGreatStuff : IExternalCommand

{

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)

{

UIApplication uiApp = commandData.Application;

return DoSomeGreatStuffExecute(uiApp);

}

}

 

Which calls a routine to show your radio button form:

public static Result DoSomeGreatStuffExecute(UIApplication uiApp)

{

RvtDoc doc = uiApp.ActiveUIDocument.Document;

// get user options - show form

if (RadioButtonForm.RadioButtonFormShowDialog(out UserSelection) == true)

{

// do some magic in Revit

}

return Result.Succeeded;

}

 

I know this is a bit scrappy, hopefully it helps. Dale

 

 




______________
Yes, I'm Satoshi.