Hi there. I got this plugin that needs a simple string input by the user. I thought this was gonna be an easy task using something like TaskDialog but I haven´t found anything on the API or this forum to make this. I know that I can use windows form but I was wondering if there is something in the Revit API that I can use for this task so I can avoid using windows form and also be able to use this as a macro.
Thanks you. Regards.
Solved! Go to Solution.
Hi there. I got this plugin that needs a simple string input by the user. I thought this was gonna be an easy task using something like TaskDialog but I haven´t found anything on the API or this forum to make this. I know that I can use windows form but I was wondering if there is something in the Revit API that I can use for this task so I can avoid using windows form and also be able to use this as a macro.
Thanks you. Regards.
Solved! Go to Solution.
Solved by yimin.chenTW. Go to Solution.
Hi @jjesusdelpino ,
I guess the simplest way is to create a WinForm with textbox for users to input.
But if you really try to avoid using WinForm as much as possible, there is a workaround, you can try to add a textbox in your ribbon panel by adding code below:
TextBoxData itemData1 = new TextBoxData("itemName1"); Autodesk.Revit.UI.TextBox item1 = ribbonPanel.AddItem(itemData1) as Autodesk.Revit.UI.TextBox; item1.Value = "Input something here..."; item1.ToolTip = itemData1.Name; // Can be changed to a more descriptive text. Uri uriImage = new Uri(@"path of the image"); BitmapImage Image1 = new BitmapImage(uriImage); item1.Image = Image1; item1.ShowImageAsButton = true; item1.EnterPressed += CallbackOfTextBox;
And your event:
public void CallbackOfTextBox(object sender, Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs args) { Autodesk.Revit.UI.TextBox textBox = sender as Autodesk.Revit.UI.TextBox; TaskDialog.Show(textBox.Value.ToString(), textBox.Value.ToString()); }
Though I don't think it's a good way, and maybe there are some more ways to do but right now I can only think of this.
Hope this helps.
Hi @jjesusdelpino ,
I guess the simplest way is to create a WinForm with textbox for users to input.
But if you really try to avoid using WinForm as much as possible, there is a workaround, you can try to add a textbox in your ribbon panel by adding code below:
TextBoxData itemData1 = new TextBoxData("itemName1"); Autodesk.Revit.UI.TextBox item1 = ribbonPanel.AddItem(itemData1) as Autodesk.Revit.UI.TextBox; item1.Value = "Input something here..."; item1.ToolTip = itemData1.Name; // Can be changed to a more descriptive text. Uri uriImage = new Uri(@"path of the image"); BitmapImage Image1 = new BitmapImage(uriImage); item1.Image = Image1; item1.ShowImageAsButton = true; item1.EnterPressed += CallbackOfTextBox;
And your event:
public void CallbackOfTextBox(object sender, Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs args) { Autodesk.Revit.UI.TextBox textBox = sender as Autodesk.Revit.UI.TextBox; TaskDialog.Show(textBox.Value.ToString(), textBox.Value.ToString()); }
Though I don't think it's a good way, and maybe there are some more ways to do but right now I can only think of this.
Hope this helps.
Clearly this is a solution I hadn´t considered. Very original and do the point. Anyway this seems to be even harder than forms so im guesssing thats what Im gonna use. Thanks you so much for your anwser. Very complete and very didactid.
Regards.
Clearly this is a solution I hadn´t considered. Very original and do the point. Anyway this seems to be even harder than forms so im guesssing thats what Im gonna use. Thanks you so much for your anwser. Very complete and very didactid.
Regards.
can i read the textbox value in another Clasees?
For example i want to input value e.g. "150" and run another command which will use this "150" value in ot own calculations, and i dont need to change value every time i run other command and dotn want to press enter.
I want to use it like a storage for my value, is it possible? cant access to any textbox commands from other class
can i read the textbox value in another Clasees?
For example i want to input value e.g. "150" and run another command which will use this "150" value in ot own calculations, and i dont need to change value every time i run other command and dotn want to press enter.
I want to use it like a storage for my value, is it possible? cant access to any textbox commands from other class
Hi,
you can use Microsoft.VisualBasic namespace
using Microsoft.VisualBasic; string input = Interaction.InputBox("Prompt", "Title");
like in this example
https://stackoverflow.com/questions/97097/what-is-the-c-sharp-version-of-vb-nets-inputdialog
Hi,
you can use Microsoft.VisualBasic namespace
using Microsoft.VisualBasic; string input = Interaction.InputBox("Prompt", "Title");
like in this example
https://stackoverflow.com/questions/97097/what-is-the-c-sharp-version-of-vb-nets-inputdialog
Hello Yimin,
Thank you, this was useful to me. Do you know how to set up the Width of that text box ? @jeremytammik I read the description of the Width property but I don't quite understand what unit sheets are, and how they would correspond to my desired units (I thought I could pick something like "max number of characters", and Font size).
Angelo
Hello Yimin,
Thank you, this was useful to me. Do you know how to set up the Width of that text box ? @jeremytammik I read the description of the Width property but I don't quite understand what unit sheets are, and how they would correspond to my desired units (I thought I could pick something like "max number of characters", and Font size).
Angelo
Can't find what you're looking for? Ask the community or share your knowledge.