SelectionListBox Documentation
A custom IronPython control for selecting entities in Alibre Script using filtered ListBox UI.

Overview
SelectionListBox
allows users to select entities (faces, edges, planes, etc.) from the Alibre 3D workspace. Each control is configured via a Tag
to define the selection type. It supports single or multi-selection, filtering, and optional AutoNext navigation.
UI Features
- Clear Button: Removes all selections.
- Context Menu: Right-click to clear or remove selected items.
- Highlighting: Selected items are shown in the Alibre workspace.
- Threading: Forms using this control should run in an STA thread.
Usage Example
import clr
import os
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Form, TableLayoutPanel, DockStyle, Label
from System.Threading import Thread, ThreadStart
sys.path.append(ScriptFolder) # Ensure SelectionListBox is accessible
from SelectionListBox import SelectionListBox
class MyThreadVarsClass():
started = 0
form1 = None
MyThreadVars = MyThreadVarsClass()
class MySelectionForm(Form):
def __init__(self):
self.Text = "Selection Example"
self.Width = 400
self.Height = 200
self.TopMost = 1
self.FormClosed += self.onFormClosed
layout = TableLayoutPanel()
layout.Dock = DockStyle.Fill
layout.RowCount = 3
layout.ColumnCount = 2
layout.AutoSize = True
self.Controls.Add(layout)
# — Edges —
self._lbl_edges = Label()
self._lbl_edges.Text = 'Edges'
layout.Controls.Add(self._lbl_edges, 0, 0)
self._SLB_edges = SelectionListBox()
self._SLB_edges.Dock = DockStyle.Fill
self._SLB_edges.Tag = 'Edges'
layout.Controls.Add(self._SLB_edges, 1, 0)
# — Face —
self._lbl_face = Label()
self._lbl_face.Text = 'Face'
layout.Controls.Add(self._lbl_face, 0, 1)
self._SLB_face = SelectionListBox()
self._SLB_face.Dock = DockStyle.Fill
self._SLB_face.Tag = 'Face'
self._SLB_face.AutoNext = 1
layout.Controls.Add(self._SLB_face, 1, 1)
# — Planes —
self._lbl_planes = Label()
self._lbl_planes.Text = 'Planes'
layout.Controls.Add(self._lbl_planes, 0, 2)
self._SLB_planes = SelectionListBox()
self._SLB_planes.Dock = DockStyle.Fill
self._SLB_planes.Tag = 'Planes'
layout.Controls.Add(self._SLB_planes, 1, 2)
def onFormClosed(self, sender, e):
if self._SLB_edges.PreviousSelection.Count >= 1:
for i in range(0, self._SLB_edges.Items.Count):
selectionName = str(self._SLB_edges.Items.Item[i])
selectionProxy = self._SLB_edges.PreviousSelection.Item(i)
print(selectionName, selectionProxy)
self.Close()
def thread_form():
global MyThreadVars
MyThreadVars.form1 = MySelectionForm()
MyThreadVars.started = 1
MyThreadVars.form1.ShowDialog()
MyThreadVars.started = 0
t = Thread(ThreadStart(thread_form))
t.ApartmentState = System.Threading.ApartmentState.STA
t.Start()
loop_count = 0
while not MyThreadVars.started and loop_count < 10:
Thread.CurrentThread.Join(100)
print('Waiting for form...')
loop_count += 1
if MyThreadVars.started:
while MyThreadVars.started:
Thread.CurrentThread.Join(100)
print('closed')
Tags & Behavior
Tag | Selection Type | AutoNext Support | Description |
---|---|---|---|
‘Face’ | Single | ✅ Yes | Select a single face |
‘Faces’ | Multiple | ❌ No | Select multiple faces |
‘Edge’ | Single | ✅ Yes | Select a single edge |
‘Edges’ | Multiple | ❌ No | Select multiple edges |
‘Vertex’ | Single | ✅ Yes | Select a single vertex |
‘Vertices’ | Multiple | ❌ No | Select multiple vertices |
‘Plane’ | Single | ✅ Yes | Select a single reference plane |
‘Planes’ | Multiple | ❌ No | Select multiple reference planes |
‘Axis’ | Single | ✅ Yes | Select a single axis |
‘Axes’ | Multiple | ❌ No | Select multiple axes |
‘Point’ | Single | ✅ Yes | Select a single reference point |
‘Points’ | Multiple | ❌ No | Select multiple reference points |
‘Sketch2D’ | Single | ✅ Yes | Select a single 2D sketch |
‘Sketches2D’ | Multiple | ❌ No | Select multiple 2D sketches |
‘Sketch3D’ | Single | ✅ Yes | Select a single 3D sketch |
‘Sketches3D’ | Multiple | ❌ No | Select multiple 3D sketches |
‘Part’ | Single | ✅ Yes | Select a single part |
‘Parts’ | Multiple | ❌ No | Select multiple parts |
‘Assembly’ | Single | ✅ Yes | Select a single assembly/component |
‘Assemblies’ | Multiple | ❌ No | Select multiple assemblies/components |
Developer Notes
Constructor
SelectionListBox()
Initializes layout, timer, clear button, context menu, and filtering logic.
Key Properties & Methods
Name | Description |
---|---|
Tag | Defines selection filter |
AutoNext | Moves focus to next control (if singular) |
PreviousSelection | Stores last valid selection set |
ClearAll() | Clears all items |
RemoveSelected() | Removes selected items |
add_selection_item() | (Internal) Adds item to list |
apply_filter_by_tag() | (Internal) Applies filter using Filters class |
Filtering
- Uses
Filters
class to apply Alibre selection filters. - Limited to types supported by Alibre API.
- Tag values map to methods like
FacesOnly()
,EdgesOnly()
, etc.
Integration
- Use
sys.path.append()
to access the class. - Run forms in STA threads for stability.
- AutoNext uses
Parent.SelectNextControl()
.
Style
- Avoids
str.format()
- Uses single quotes
- Clear naming and layout anchoring