Manage

Select

Model

Analyze

Collaborate

Stay up to date

Interact

Run Python

The "Run Python" command in BIMO Add-in for Revit allows users to execute Python scripts directly within Autodesk Revit. This provides an opportunity to automate tasks, perform complex calculations, and manipulate Revit elements using Python code.

Configuration Settings

Upon activating the command, users can input their custom Python script. The script will be executed in the context of the current Revit document. The following sections explain how to set up and execute Python scripts with access to Revit API objects.

  • Python Script :

    Python Script :

    Enter the Python script you wish to run. The script can interact with Revit's API, allowing for a wide range of actions from retrieving data to modifying elements in the model.

    Enter the Python script you wish to run. The script can interact with Revit's API, allowing for a wide range of actions from retrieving data to modifying elements in the model.

Available Variables

Several pre-defined variables are available for use within your Python script. These provide access to Revit's active document, application context, and user interface elements.

  • __revit__ :

    __revit__ :

    Refers to the UIApplication object representing the current Revit application instance. This provides access to overall application settings and commands.

    Refers to the UIApplication object representing the current Revit application instance. This provides access to overall application settings and commands.

  • __uiapp__ :

    __uiapp__ :

    Another reference to the UIApplication object, interchangeable with __revit__.

    Another reference to the UIApplication object, interchangeable with __revit__.

  • __doc__ :

    __doc__ :

    Refers to the active Document object. This is the current project or family document loaded in Revit, which the script can interact with, including accessing elements and modifying the model.

    Refers to the active Document object. This is the current project or family document loaded in Revit, which the script can interact with, including accessing elements and modifying the model.

  • __uidoc__ :

    __uidoc__ :

    Refers to the UIDocument object, which provides additional user interface-related information and access to the active Revit document.

    Refers to the UIDocument object, which provides additional user interface-related information and access to the active Revit document.

Executing the Script

After entering your Python script, click the "OK" button to execute it. The command will run the script within the Revit environment, and any output will be displayed through Revit's task dialog.

  • Output :

    Output :

    To display results or messages during script execution, use the standard Python print() function. For example:

    print("Document Title: " + __doc__.Title)
    This will output the title of the current Revit document.

    To display results or messages during script execution, use the standard Python print() function. For example:

    print("Document Title: " + __doc__.Title)
    This will output the title of the current Revit document.

Post-Execution

After successful execution, the output of the script will be shown in a dialog box, either displaying the success message or error details. If there is an issue in the script, the error message and traceback will be presented for debugging.

BIMO Tools © 2024. All rights reserved.

2024.11.29-7a79596

An error has occurred. This app may no longer respond until reloaded. Reload 🗙