This template contains the full scaffolding required to publish a function to the Automate environment.
It also has some sane defaults for development environment setups.
# 🚀 Automate Revit Rooms and Areas Scheduling – No Coding Required
## Getting started
Easily export all **Rooms** and **Areas** by Level into an Excel file in seconds, ensuring **accurate and up-to-date project data**. This automation **eliminates manual effort**, **reduces errors**, and provides a **structured format** for further analysis.
1. Use this template repository to create a new repository in your own / organization's profile.
Seamlessly integrate the exported data with **reporting tools** or **dashboards** to enhance project tracking and decision-making.
Register the function
---
### Add new dependencies
## 📏 Follow Your Standards
To add new Python package dependencies to the project, use the following:
`$ poetry add pandas`
Define **Area KPI metrics** based on your company’s standards to ensure **consistency and accuracy** across all projects.
### Change launch variables
With clear benchmarks, you can:
✅ Track performance
✅ Optimize space utilization
✅ Make data-driven decisions
Describe how the launch.json should be edited.
By automating this process, each **new model version** can be compared against predefined criteria—ensuring compliance and efficiency.
### Github Codespaces
---
Create a new repo from this template, and use the create new code.
## 🔎 Never Miss a Detail
### Using this Speckle Function
Every time a **new model version** is published from Revit, all **Rooms and/or Areas** are **automatically exported** into an Excel file.
1. [Create](https://automate.speckle.dev/) a new Speckle Automation.
1. Select your Speckle Project and Speckle Model.
1. Select the deployed Speckle Function.
1. Enter a phrase to use in the comment.
1. Click `Create Automation`.
This guarantees that:
✔ No data is missed
✔ You have a reliable record of spatial changes over time
✔ Your project data remains structured and up to date
## Getting Started with Creating Your Own Speckle Function
---
1. [Register](https://automate.speckle.dev/) your Function with [Speckle Automate](https://automate.speckle.dev/) and select the Python template.
1. A new repository will be created in your GitHub account.
1. Make changes to your Function in `main.py`. See below for the Developer Requirements and instructions on how to test.
1. To create a new version of your Function, create a new [GitHub release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) in your repository.
## 📊 **See Results Clearly**
## Developer Requirements
Each time a **new model version** is published, Revit will export **all Rooms and/or Areas** for each Level into an Excel file, providing a **clear and structured** dataset for analysis.
1. Run `poetry shell && poetry install` to install the required Python packages.
### ✨ **Optional: Set Up KPI Metrics**
## Building and Testing
You can track key **Area KPI metrics** such as:
The code can be tested locally by running `poetry run pytest`.
- **NUA** – Net Usable Area
- **NIA** – Net Internal Area
- **NLA** – Net Leasable Area
- **GIA** – Gross Internal Area
- **GEA** – Gross External Area
- **GLA** – Gross Leasable Area
- **GBA** – Gross Building Area
### Building and running the Docker Container Image
### ⚡ How to Define KPI Metrics
Running and testing your code on your machine is a great way to develop your Function; the following instructions are a bit more in-depth and only required if you are having issues with your Function in GitHub Actions or on Speckle Automate.
⚠️To calculate a KPI metric, use the **exact names** of the **Rooms** and/or **Areas** you want to combine.
#### Building the Docker Container Image
#### Example: **Office Building – Net Internal Area (NIA)**
In an office building, **NIA** is typically calculated by summing up the areas for:
- **Office**
- **Amenities**
- **Storage**
- **Primary Circulation**
The GitHub Action packages your code into the format required by Speckle Automate. This is done by building a Docker Image, which Speckle Automate runs. You can attempt to build the Docker Image locally to test the building process.
Simply separate these names with commas when defining your metric.
To build the Docker Container Image, you must have [Docker](https://docs.docker.com/get-docker/) installed.
Once you have Docker running on your local machine:
1. Open a terminal
1. Navigate to the directory in which you cloned this repository
Once the GitHub Action has built the image, it is sent to Speckle Automate. When Speckle Automate runs your Function as part of an Automation, it will run the Docker Container Image. You can test that your Docker Container Image runs correctly locally.
1. To then run the Docker Container Image, run the following command:
`docker run—-rm speckle_automate_python_example` tells Docker to run the Docker Container Image we built earlier. `speckle_automate_python_example` is the name of the Docker Container Image. The `--rm` flag tells Docker to remove the container after it has finished running, freeing up space on your machine.
The line `python -u main.py run` is the command run inside the Docker Container Image. The rest of the command is the arguments passed to the command. The arguments are:
- `'{"projectId": "1234", "modelId": "1234", "branchName": "myBranch", "versionId": "1234", "speckleServerUrl": "https://speckle.xyz", "automationId": "1234", "automationRevisionId": "1234", "automationRunId": "1234", "functionId": "1234", "functionName": "my function", "functionLogo": "base64EncodedPng"}'` - the metadata that describes the automation and the function.
- `{}` - the input parameters for the function the Automation creator can set. Here, they are blank, but you can add your parameters to test your function.
- `yourSpeckleServerAuthenticationToken`—the authentication token for the Speckle Server that the Automation can connect to. This is required to interact with the Speckle Server, for example, to get data from the Model.
## Resources
- [Learn](https://speckle.guide/dev/python.html) more about SpecklePy and interacting with Speckle from Python.
automate_context.mark_run_success("All data sent successfully! Download your file below.")
except:
automate_context.mark_run_failed("An error occurred while writing to the file. Ensure that the parameters 'Level,''Name,' and 'Area' exist. Additionally, verify that the area/room names are correctly typed and separated by commas.")
automate_context.mark_run_failed("An error occurred while writing to the file. Ensure that the parameters Areas or Rooms category exist. Additionally, verify that the area/room names are correctly typed and separated by commas.")
# Function to sum area for each group, ensuring missing levels return 0
#These are test inputs, only work when testing localy.
FunctionInputs(
file_name="TestNameABC",
inlcude_areas=True,
file_name="TestName",
inlcude_areas=False,
inlcude_rooms=True,
nua_list="Elevator E1, Level 5 Gross, Live/Work Unit, Machine RM",
nia_list="",
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.