In Revit, users often need to input specific data before executing a program. To implement forms in Revit, you can use the following example code:
ParkingForm frmDlg = new ParkingForm();
frmDlg.ShowDialog();
if (frmDlg.DialogResult == DialogResult.OK)
{
pref = frmDlg.Val;
}
else
{
return Result.Cancelled;
}
The ParkingForm class inherits from Form, and its implementation is shown below:
public partial class ParkingForm : Form
{
public ParkingForm()
{
InitializeComponent();
}
// Define Val string to get or set the value of textBox1
public string Val
{
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
private void button2_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
}
This example demonstrates how to add a form within Revit, allowing users to enter values into a text box on the form and then pass those values back to Revit.
xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat













Must log in before commenting!
Sign Up