What's new

New Python 3 package for Alibre Design programming - alibrex

stepalibre

API/Scripting Guru
alibrex is available on PYPI


alibrex is a Python 3 package for the Alibre Design AlibreX API. This package could be considered a full replacement for Alibre Script with Visual Studio Code, PyCharm, JupyterLab Notebooks, any Python supported text editor or IDE replacing the Alibre Script addon.

Documentation:

The demos, testing files, and helpers are the documentation, along with AlibreX.chm. I suggest exploring all the test files, demos and notebooks to understand how to build with alibrex.

Two good ones:



alibrex_package is an ongoing effort I'm making it available while I continue testing and building out missing areas. The process is slow and tedious.

alibrex is not compatible with Alibre Script code you must port your scripts if you want them working in Python 3.

If Alibre Script isn't powerful enough, you want to debug and step through code, program Alibre Design from a system terminal or it isn't working out for you, alibrex may be worth trying.

1. Install Python 3.13
- Get it from https://python.org/downloads/
- Run the installer
- Check the box "Add python.exe to PATH" on the first screen
- Click Install Now
2. Open PowerShell
- Press the Windows key
- Type powershell
- Press Enter
3. Confirm Python works
python --version
- Should print Python 3.13.x
4. Install alibrex
pip install alibrex
5. Open Alibre and any part
- Start Alibre Design
- File → New → Part
6. Test it
python -c "from alibrex import CurrentPart; print(CurrentPart().Name)"
- Should print the part's name
7. Done. You can now write scripts.
 
I am adding new content and fixing issues as needed so be sure to revisit the repo to get the latest. If anything was broken, I may have fixed it.

Next wave of examples will be GUI applications.

The package should work with any version of Alibre Design, however any API calls that are for specifically V29 (PDM), won't work without V29. Nothing in the package is locked to a specific version in terms of runtime checking the version. That is intentional. You can check the version of the running Alibre yourself to gate code paths.


 
Something to look out for are ComProxies (see images). ComProxies are AlibreX COM API representation in Python.

If the Python LSP or debugger don't provide valid objects, here are a few solutions:

Find paths that hit ComProxies and wrap them with your own function.
Restructure your program to avoid ComProxies.

There is a path to reference an object, property or method.

Code path/object path/function path:

##0## -> ##1## -> ##2## -> ##3## -> ##4## -> ##5## -> ##6## -> ##7##

Entry point:

alibrex -> ##1## -> ##2## -> ##3## -> ##4## -> ##5## -> ##6## -> ##7##

How to reference a line entity ##7##?

alibrex -> ##1## -> ##2## -> ##3## -> ##4## -> ##5## -> ##6## -> line

Steps:

##3## -> features collection

##4## -> sketch collection

##5## -> a sketch

##6## -> entities collection

##7## -> a entity

Full path example:

alibrex -> session -> partsession -> partfeatures -> sketches -> sketch -> entities -> line

If your path is hitting ComProxy objects, that is a candidate for a wrapper.

alibrex -> session -> partsession -> ComProxy

The only way to improve handling of ComProxies is building and debugging programs, finding and wrapping them to produce valid objects and types. AlibreX incomplete API surface compounds COM issues.

Test files in the GitHub repo were made to help identify and wrap ComProxies.

1779557568580.png
1779559639367.png

API coverage info:

With an incomplete API you will make assumptions that lead to dead ends. There are placeholder stubs that add noise, readonly properties, missing methods and properties throughout.

The AlibreX API and chm were used.
Errors and inconsistencies carried over.
These tables are summaries from the raw data. They show what's missing in the API.

1779562633434.png
1779571611155.png
1779562639473.png
1779562643441.png
1779562656235.png
1779562662925.png
1779562674647.png
1779562679452.png

The problem: API gaps + COM + Python = :mad:
 
Last edited:
I want to give a brief update. This thread was an early introduction to the package. My goal is simple, adopt Alibre Script conveniences while providing the full AlibreX API with Python 3. I have a few updates planned after the V29 release, then minor fixes and new examples as needed. If you have any questions or issues, the project pages will have contact instructions. You can post questions and comments here, but the main sources, GitHub and PyPI, will have contact instructions. Thanks for the help over the years with Alibre Script and AlibreX. It really got me started in the right direction.
 
Well, I have an idea.
I hate the Gigabyte and Terabyte. I think all of this is "bytes bureaucracy" that infects our computer.
We should have a Python or C++ resource for parts with specific standard, so we will save a lot of gigabytes. When you need a part, you just run the script and get it quickly.
1782976286340.png
 
Yes, the size you need is created on demand. It solves the "too many files on disk" issue. When you need a part, you run the toolbox process, it creates the size you need. A Python, C# or C++ API solution is completely separate. You could copy the toolbox data and build a scriptable system.
 
Back
Top