BlocklyPy Commander for VSCode

A Visual Studio Code extension to interact with LEGO® Hubs running the Pybricks firmware.
Features
Streamline your Pybricks coding experience with:
- Connect/disconnect your Hub via Bluetooth
- Start/stop programs directly from VS Code
- Compile and upload Python scripts from your workspace
- View compilation and runtime errors in your code
- Auto-connect to the last used hub
- Auto-start your script on save
- Open and convert majority of the LEGO robotics file formats
- Receive program status and display hub output messages
Getting Started
- Install this extension from the VS Code Marketplace.
- Connect your LEGO Hub via Bluetooth.
- Open your Python or LEGO robotics files.
- Use the command palette (
Ctrl+Shift+P
) to access Pybricks commands.
This extension opens, displays, analyzes, and converts most major LEGO robotics file formats for easy onboarding, backup, and analysis.
Features for LEGO Files
- Pseudocode representation of block programs
- Graphical preview of block-based code
- Module dependency visualization of code structure
- Convert block code to compatible Pybricks Python code*
*Experimental: Please verify converted code and provide feedback.
SPIKE Prime (45678) and SPIKE Essentials (45345) kit and Robot Inventor (51515) kit for word-blocks and icon-blocks.
- SPIKE v2 (
.llsp
) and v3 (.llsp3
)
- Robot Inventor (
.lms
)
LEGO® MINDSTORMS® EV3 (31313) graphical-blocks and compiled-binary.
- EV3 Classroom (
.lmsp
)
- EV3 Lab (
.ev3
)
- EV3 iPad (
.ev3m
)
- EV3 Lab Compiled Binary (
.rbf
)
LEGO® WeDo 2.0 (45300) graphical-blocks.
- LEGO WeDo 2.0 project files (
.proj
)
- Pybricks Python (
.py
), supports multiple files.
Limitations
- Only custom modules in the same folder as the main script are supported
- Package structures and relative imports are not currently supported
- Runtime error locations may be inaccurate after changing tabs
Guide: Fun First Things to Explore
- Connect to a SPIKE Pybricks Hub via Bluetooth
- Reconnect to the last Pybricks Hub via Bluetooth
- Check out the auto-connect to the last Pybricks Hub via Bluetooth on VSCode start
- Open a Pybricks Python file, compile and upload
- Use the auto-start feature by adding
# LEGO autostart
header
- Check the feedback for any runtime error reported by the hub
- Check the feedback from any print statements reported by the hub
- Use imports from other local python modules
- Open a depedency graph to explore the project call dependencies
- Open a SPIKE hub version 3 or version 2 file to check the blockly preview
- Explore pseudocode to see a simplified text representation of the SPIKE code
- Check the converted Pybricks Python code, compile and run it directly
- Observe the dependency call graph for the SPIKE file
- Make changes on the SPIKE source file in the LEGO app, and see instant updates
- Open a Robot Inventor MINDSTORMS App file and check the above features
- Open a SPIKE Essential Iconblocks file and check the above features
- Open an EV3 classic EV3-G file and check the pseudocode and graph features
- Check the converted python code for the EV3G file; compile and run it
- Download a compiled and running binary (.rbf) file from your EV3 hub and check the pseudocode, python code and graph features
- Open an EV3 iPad file and check the pseudocode, python and graph features
- Open an EV3 classroom file and check the pseudocode, python and graph features
- Open a WeDo 2.0 file and check the pseudocode and python features
Acknowledgements
This project is rooted on the work of Song-Pei Du dusongpei and on the work of the Pybricks authors, Laurens Valk and David Lechner.
License
This project is licensed under the MIT License.
Screenshot
