# Exporting Pre-Post maxillofacial quantification models to GLB

**URL:** <https://discourse.slicer.org/t/exporting-pre-post-maxillofacial-quantification-models-to-glb/48209>\
**Category:** Development\
**Created:** [September 21, 2026, 1:57pm UTC](https://discourse.slicer.org/t/exporting-pre-post-maxillofacial-quantification-models-to-glb/48209 "2026-09-21T13:57:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvaro](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@alvaro](https://discourse.slicer.org/u/alvaro)\
**Post date:** [September 21, 2026, 1:57pm UTC](https://discourse.slicer.org/t/exporting-pre-post-maxillofacial-quantification-models-to-glb/48209/1 "2026-09-21T13:57:51Z")

</div>

Hi everyone,

I am working on a custom scripted module in 3D Slicer tailored for **Pre-Post surgical maxillofacial and orthognathic studies**.

My goal is to automate the export workflow for clinical web visualization:

1. Combine and center multiple quantification models (such as Airway and Mandible distance maps) into a single `.glb` file with baked vertex colors.
2. Export clean, transparent individual `Color Legend` images corresponding to each model’s active scalars.

**What I have achieved so far:**  
I have successfully built the core logic of the script, handling the VTK coordinate transformations (-Y orientation and centering), scalar extraction, vertex color baking, and mesh combination into GLB using `trimesh`.

**The roadblock I am facing:**  
When trying to capture the individual color legends (`Color Legend` / color bars) by isolating models and grabbing/cropping the 3D view widget, the resulting PNGs either cut off parts of the 3D model, fail to capture the left-side legend cleanly, or end up with rendering artifacts. I haven’t been able to get this part fully right.

**What I would love to achieve / Need help with:**

1. Someone to help me spot and fix the bug in my legend-export approach (or point me to the native Slicer API to directly export a model’s active color legend as a clean transparent PNG).
2. Guidance on how to properly structure this into a GUI module where I can interactively select specific models, adjust display parameters (like opacity/transparencies), and trigger the batch export of the GLB and its scalar color legends.

Here is a snippet of my current approach:

```python
# Iterating visible models, isolating them, and attempting to grab the view/legend
for modelNode in quantificationModels:
    # ... isolation and mesh baking ...
    fullImage = ctk.ctkWidgetsUtils.grabWidget(viewWidget)
    # ... cropping logic that currently struggles with clean isolation ...

```
