Examples
The following code samples demonstrate the UI features of Launchpad.
Various UI Controls
// Get list of strings for combo box
List<string> tblockList = new List<string>();
tblockList.Add("Item 1");
tblockList.Add("Item 2");
tblockList.Add("Item 3");
// Get all views for list box
List<View> viewList = new FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_Views)
.Cast<View>()
.ToList();
string textInputLabel = "Text Input Control:";
string comboBoxLabel = "Combobox Control";
string listBoxLabel = "List Box Control";
string checkboxLabel = "Checkbox Control";
string radioButtonLabel = "Radio Buttons:";
string fileSelectionLabel = "Select a File:";
string sliderLabel = "Select a Number:";
var results = UI.CreateCustomForm("UI Sample Script", 400, 910, form =>
{
// Add a header
form.AddHeader("Launchpad UI Sample Script", 18);
// Add your form controls
form.AddTextInput(textInputLabel, "A-");
form.AddComboBox(comboBoxLabel, tblockList);
form.AddListBox(listBoxLabel, viewList, v => v.Name, allowMultiple: true, height: 200);
// Add an italicized note about view placement
form.AddLabel("This is a sample lable. It just displays text.", 12, true);
form.AddCheckbox(checkboxLabel, true);
List<string> options = new List<string>{"Floor Plan", "Reflected Ceiling Plan", "Section"};
form.AddRadioButtons(radioButtonLabel, options, options[0]);
form.AddFileSelector(fileSelectionLabel); // change to true for multiple files
form.AddSlider(sliderLabel, 1,100,50,1);
form.AddLink("Help", "https://www.archsmarter.com", 12);
});
// Get results
if(results.Success)
{
string textInputResult = results.GetStringResult(textInputLabel);
FamilySymbol comboBoxResult = results.GetElementResult(comboBoxLabel) as FamilySymbol;
List<View> listBoxResults = results.GetResultList<View>(listBoxLabel);
bool checkboxResult = results.GetBoolResult(checkboxLabel);
string radioButtonResult = results.GetStringResult(radioButtonLabel);
string fileSelectionResult = results.GetStringResult(fileSelectionLabel);
double sliderResult = results.GetSliderResult(sliderLabel);
Console.WriteLine("The results are:");
Console.WriteLine(textInputResult);
Console.WriteLine(comboBoxResult.Name);
foreach(Element elem in listBoxResults)
{
Console.WriteLine(elem.Name);
}
Console.WriteLine(checkboxResult);
Console.WriteLine(radioButtonResult);
Console.WriteLine(fileSelectionResult);
Console.WriteLine(sliderResult.ToString());
}
Progress Bar
Timer
Last updated