Skip to content

the-tool-store/alibre-python-shell-addon-v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alibre Python Shell Add-on V2

An interactive IronPython shell and script editor that runs inside Alibre Design and connects to the live modeling session through the AlibreX and AlibreScript APIs.

The add-on opens a split window with an AvalonEdit script editor on top and an IronPython 2.7 REPL below. Code typed in either pane runs against the active Part, Assembly, or Drawing session. It builds as a .NET Framework 4.8.1 (x64) add-on and references Alibre Design 29.0.0.29060.

Table Of Contents

What Is Here

  • An IronPython 2.7 console (REPL) that executes code against the active Alibre session in real time.
  • A split-pane window: an AvalonEdit script editor on top and the live console below, separated by a draggable splitter.
  • Run the whole script or just the selected text from the editor with the Run button or F5.
  • The current session is exposed to the console as the cs variable, and the AlibreScript API is imported at startup.
  • Code completion with a side completion list and Tab-key insertion and cycling, plus Python syntax highlighting.
  • An editor toolbar for open, save, undo, redo, cut, copy, paste, word wrap, line numbers, and end-of-line markers, and a Clear action on the console.
  • A dark themed UI, with a dark title bar on Windows 10 and later.
  • Menu entry enabled in Part, Assembly, and Drawing sessions.

Official Alibre Resources

Alibre's official resources for API development and AI/LLM/agent workflows: https://www.alibre.com/api/

Requirements

  • Alibre Design (built and referenced against version 29.0.0.29060).
  • .NET Framework 4.8.1 (x64).
  • IronPython 2.7.10.

Quick Start

  1. Build source/AlibrePythonShellAddonV2.sln in Release configuration.
  2. Register the add-on with the AlibrePythonShellAddonV2.adc manifest (see Installation).
  3. Restart Alibre Design, open a Part, Assembly, or Drawing, and launch the add-on from its menu entry.

Installation

  1. Build source/AlibrePythonShellAddonV2.sln in Release configuration.
  2. Copy the build output, the AlibrePythonShellAddonV2.adc manifest, and the bundled Python files (IronPythonConsole.py and AlibrePython/) into an Alibre Design add-ons folder.
  3. The .adc manifest registers the add-on as loaded at startup and adds an "Alibre Python Shell Addon V2" menu entry.
  4. Restart Alibre Design so the add-on loads.

Usage

  1. Open a Part, Assembly, or Drawing in Alibre Design.
  2. Launch the add-on from its "Alibre Python Shell Addon V2" menu entry to open the shell window.
  3. Type Python in the lower console and press Enter to run it interactively, or write a script in the upper editor and press F5 (or Run) to run all of it or the current selection.
  4. Use the cs variable to reach the current session, and the AlibreScript API for modeling operations.

Key Files

File Purpose
source/AlibrePythonShellAddonV2.sln Visual Studio solution for the add-on.
source/AlibrePythonShellAddonV2.adc Alibre add-on manifest: registers the DLL, menu text, and add-on identifier (GUID).
source/AlibreAddOn.cs Add-on entry points (AddOnLoad, GetAddOnInterface) that Alibre calls on load.
source/AlibrePythonShellAddonV2.cs IAlibreAddOn implementation: menu tree, per-session menu state, and launching the shell window.
source/Form1.cs WinForms host window that embeds the WPF control and applies the dark title bar.
source/Form1.Designer.cs Designer layout for the host window, including the WPF ElementHost.
source/MainUserControl.xaml Split editor-and-console layout, toolbar, and completion list.
source/MainUserControl.xaml.cs UI logic: run, file open/save, code completion, and binding the cs session variable.
source/IronPythonConsole.py Startup script that adds Alibre Design paths and imports AlibreX and AlibreScript.
source/AlibrePython/__init__.py Package init that imports AlibreX and the AlibreScript API.
source/Resources/Python.xshd Python syntax highlighting definition for the editor.

Key Folders

Folder Purpose
source/ Add-on C# project, solution, manifest, and Python startup files.
source/PythonConsoleControl/ WPF IronPython console control project: REPL host, completion, and highlighting.
source/AlibrePython/ Python package imported into the console at startup.
source/Resources/ Editor resources, including the Python highlighting definition.
documentation/ Placeholder for documentation (currently empty).
reviews/ Code review notes.
submodules/ Placeholder for git submodules (currently empty).
.github/ This README, contribution guide, and issue and pull request templates.

Notes

  • The IronPython runtime is 2.7.10, so scripts should stay Python 2.7 compatible.
  • IronPythonConsole.py hard-codes Alibre Design paths under C:\Program Files\Alibre Design 29.0.0.29060; adjust them for a different install location or version.
  • The add-on references Alibre Design 29.0.0.29060; other versions are untested.
  • The console needs a Part, Assembly, or Drawing session open to bind the cs variable.

License

See LICENSE.

Alibre, Alibre Design, and Alibre Script names and related materials belong to their respective owners.

About

External Python shell for Alibre Design

Resources

License

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Contributors