CalcTree Help Pages
  • What is CalcTree?
  • Getting started
    • CalcTree Pages
    • Create a CalcTree Page
    • Add a calculation
    • Collaborate with a colleague
  • Calculations
    • Parameters
      • Math formulas
        • Parameter Data Types
        • Native Functions
          • Arithmetic Functions
          • Trigonometric Functions
          • Logical & Comparison Functions
          • Matrix & Vector Functions
          • Probability & Combinatorics Functions
          • Statistical Functions
          • String Functions
          • Utility Functions
          • Other Native Functions
        • Valid Expression Syntax
      • Supported Units
      • Dropdown List Parameters
        • Linking CSV Data to Dependent Dropdowns in CalcTree
      • Parameter Settings
    • Integrations
      • Python in CalcTree
        • Adding a Python Source
        • Defining Parameters in Python
        • Referencing Other Parameters in Python
        • Working with Units in Python
        • Creating Tables and Visuals in Python
        • Consuming Files in Python
        • Using Pre-installed Python Libraries
      • Spreadsheets [Coming Soon!]
      • File Upload
        • CSV files
      • 3rd Party Software Plugins
        • Excel
        • Grasshopper
        • ETABS [v20 & v21]
        • ETABS [v22]
        • SAP 2000
        • CSI Bridge [v26]
    • Templates [Coming Soon!]
    • Optimising your calculations
  • Pages & Reports
    • CalcTree Documents
    • Static content
    • Parametric content
      • Parametric equation
      • Inputs
      • Outputs
  • Export to PDF
  • API
    • GraphQL API
      • Generating an API key
      • Queries
        • GetCalculation
        • Calculate
      • Examples
        • Bulk calculations with Python
  • Collaborate
    • Add members
    • Review and approval
    • Add stakeholders
  • Administrate
    • CalcTree Workspace
    • Versioning and Audit trail
  • CalcTree for System Administrators
Powered by GitBook
On this page
  • Example
  • Notes
  1. Calculations
  2. Integrations
  3. Python in CalcTree

Defining Parameters in Python

Define parameters in Python by assigning values to top-level variables—these become accessible throughout your CalcTree page.

PreviousAdding a Python SourceNextReferencing Other Parameters in Python

Last updated 1 day ago

In CalcTree, parameters are the core building blocks of a calculation. For Python sources, parameters are defined as top-level variables—any variable assigned at the root level of the script (i.e. not inside a function or class).

These variables are automatically extracted and added to the page's parameter list on the right-hand panel, and can be added to the page as parameters that reference the Python parameter

Example

Defining the following in a Python source will create a parameter.

a = 2

After a short moment, a will appear as a parameter under the Python source. Its value can be referenced by other sources or reused across the page.

Notes

  • Only variables defined at the top level of the script are treated as parameters

  • Variables inside functions or conditional blocks will not be extracted

  • Parameters can be scalar values, arrays, quantities with units, or tables (nested lists)