BIM World
A Professional BIM Learning Platform


Revit API Development: Creating Custom Forms

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
Like(0) 打赏
BIM WORLD » Revit API Development: Creating Custom Forms

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up