Lesson 03 - Setting Up Your Coding Workspace
Set up your coding studio. Install Python, VS Code, pyRevit, or Grasshopper to automate AEC workflows. This is the professional foundation for any architectural BIM scripting.
Introduction
Before writing any code, you need a stable environment. One place to learn Python logic. Another place to automate Revit or Rhino.
This lesson walks you through installing the core tools and connecting them to your design software.
By the end, you'll have everything ready to write your first Python script.
Lesson Overview
This section contains a general overview of topics you will learn in this lesson.
- Install Python 3.x on your system
- Install Visual Studio Code as your code editor
- Add the Python extension to VS Code
- Connect Python to Revit via pyRevit
- Connect Python to Rhino via GhPython
- Verify your setup is working
Part A: The Core Tools
These are the industry-standard tools required to write and test Python code independently of any BIM software.
Install Python 3.x (The Interpreter)
Python is the "engine" that translates your text commands into machine instructions.
Download: Python.org
Select the latest stable 3.x version.
Critical: During installation, check the box labelled "Add Python to PATH"
(This lets VS Code find Python automatically. Without it, you'll troubleshoot for 30 minutes.)
Install Visual Studio Code (Recommended)
Visual Studio Code (VS Code) is a lightweight but powerful code editor. Unlike a basic text editor, it provides syntax highlighting, error detection, and debugging tools.
Download: code.visualstudio.com
Why VS Code?
It's the professional standard. Syntax highlighting. Error detection. Debugging tools. Manages folders and version control.
You'll outgrow Notepad in a week. Start here.
Install the Python Extension for VS Code
VS Code needs a specific plugin to "understand" Python logic and provide intelligent suggestions.
- Open VS Code
- Navigate to the Extensions view (icon with four squares on the left sidebar)
- Search for "Python" (published by Microsoft)
- Click Install
Part B: Integrating with AEC Software
Once the core engine is ready, connect it to your primary design tools.
Route 1: Revit (pyRevit)
Revit does not support "raw" Python scripts out of the box in a user-friendly way. pyRevit acts as the bridge.
Installation: Download pyRevit
Function: It allows you to create custom ribbon buttons that execute Python scripts. It bypasses the need for the Revit SDK or complex C# compilation.
Route 2: Rhino (GhPython)
Rhino has deep, native integration with Python through Grasshopper.
Access: Open Grasshopper and locate the Python Script component.
Function: This component allows you to use Python to generate geometry, move points, or analyse surfaces using the RhinoCommon library.
Assignment
- Install Python 3.x on your computer (make sure you check "Add Python to PATH")
- Install Visual Studio Code
- Install the Microsoft Python Extension in VS Code
- If you use Revit: Install pyRevit
- If you use Rhino: Open Grasshopper and locate the Python Script component
- Verify your setup:
- Open VS Code
- Create a new file called
test.py - Type:
print("Setup complete") - Click the Run button (▶) in the top-right corner
- You should see:
Setup completein the terminal
Knowledge Check
The following questions are an opportunity to reflect on key topics in this lesson.
- Why do you need to check "Add Python to PATH" during installation?
- What's the difference between VS Code and a basic text editor?
- What does pyRevit do?
- Where do you find the Python component in Rhino?
Additional Resources
This section contains helpful links to related content. It isn't required, so consider it supplemental.
- If you're having trouble with Python installation, check the official Python installation guide
- For VS Code setup tips, see Getting Started with Python in VS Code
- If pyRevit isn't showing up in Revit, check the pyRevit troubleshooting guide