Overview
Once you’ve learned how to navigate MeshInspector’s API tree, the next step is to control what happens inside each tool.
Every tool panel in MeshInspector exposes its parameters, buttons, and states to Python. Through the API, you can list available controls, read their current values, modify them, and trigger actions just like pressing buttons in the UI.
This article explains:
-
How to list all tool parameters
-
How to read and write parameter values
-
How to trigger actions programmatically
-
How to ensure your updates appear correctly in the UI
Important Note
When accessing parameters for an opened tool, you must enter the tool name exactly as it appears in the MeshInspector UI, not its internal Python API name.
For example, if the panel in the interface is labeled “Section”, the correct path is:
['Section', 'ParameterName']
—not ['Object Section', 'ParameterName'], even if that’s the internal API identifier.
This distinction is crucial; using the wrong label will return no results or cause your script to fail.
Listing Tool Parameters
After opening a tool, use uiListEntries() to list every parameter and button it contains.
For example, let’s open the Mesh Healer tool from the Mesh Repair tab and explore its options.
from meshlib import mrviewerpy as mv
# Open the Mesh Repair tab and the Mesh Healer tool
mv.uiPressButton(['RibbonTabs', 'Mesh Repair'])
mv.Viewer().skipFrames(1)
mv.uiPressButton(['Ribbon', 'Mesh Healer'])
mv.Viewer().skipFrames(1)# List all parameters and buttons inside the tool
entries = mv.uiListEntries(['Mesh Healer'])
print("Entries in Mesh Healer window:", [t.name for t in entries])
Example Output
Entries in Mesh Healer window: ['##Auto Repair', '##Local Repair', 'Disconnected Parts', 'Flipped Normals', 'Holes', 'Repair Resolution', 'Repair Selected', 'Restart on Mesh Selection Change', 'Save Selection on Exit', 'Self-Intersections', 'Show Deviation Map', 'Small Tunnels', 'Thin Walls', 'Undercuts', 'Zero-Area Triangles']
Each entry corresponds to an element visible in the tool panel — buttons, toggles, or numeric fields.
Reading Parameter Values
Parameters in MeshInspector can represent numbers, booleans, or other data types.
To inspect a parameter’s current value, use one of the uiReadValue…() functions.
For numeric fields, the correct call is uiReadValueReal():
from meshlib import mrviewerpy as mv
val = mv.uiReadValueReal(['Mesh Healer', 'Repair Resolution'])
print("Current value:", val.value, "| Range:", val.min, "–", val.max)
Example Output
Current value: 1.437999963760376 | Range: 0.38999998569488525 – 3100.0
This returns an object containing the value and its allowable range.
Changing Parameter Values
You can modify a parameter using the matching uiWriteValue…() function.
Below is an example of halving the repair resolution value:
from meshlib import mrviewerpy as mv
val = mv.uiReadValueReal(['Mesh Healer', 'Repair Resolution'])
new_val = max(val.min, min(val.max, val.value * 0.5))
mv.uiWriteValueReal(['Mesh Healer', 'Repair Resolution'], new_val)
mv.Viewer().skipFrames(1)updated = mv.uiReadValueReal(['Mesh Healer', 'Repair Resolution']).value
print("Updated value:", updated)
Example Output
Updated value: 0.718999981880188
Tip
Always ensure the new value is within the valid range (val.min–val.max).
MeshInspector will ignore invalid assignments.
Triggering Actions (Buttons)
Tools often include buttons for specific operations — such as Repair Selected or Apply Transformation.
You can activate these actions with uiPressButton().
Example: triggering the Repair Selected operation in Mesh Healer.
from meshlib import mrviewerpy as mv
mv.uiPressButton(['Mesh Healer', 'Repair Selected'])
mv.Viewer().skipFrames(1)
print("Action 'Repair Selected' triggered successfully.")
Example Output
Action 'Repair Selected' triggered successfully.
This executes the same operation as clicking the button manually in the tool window.
Working with Different Value Types
The API provides several value-reading functions depending on the parameter type:
| Parameter Type | Read Function | Write Function |
|---|---|---|
| Numeric (float) | uiReadValueReal() |
uiWriteValueReal() |
| Integer | uiReadValueInt() |
uiWriteValueInt() |
| Boolean (checkbox) | uiReadValueBool() |
uiWriteValueBool() |
| String | uiReadValueString() |
uiWriteValueString() |
Each function uses the same syntax:
mv.uiReadValue<Type>(['Tool Name', 'Parameter Name'])
mv.uiWriteValue<Type>(['Tool Name', 'Parameter Name'], value)
Name Matching and Best Practices
-
Always discover parameter names dynamically using
uiListEntries().
The visible label in the interface may differ from the internal API name.
For instance, the UI label “Section” may correspond to “Object Section” internally. -
Respect case sensitivity.
The API names are exact; capitalization or spacing mismatches will cause errors. -
Use
skipFrames(1)after UI changes.
This ensures the viewer updates after pressing buttons or writing values. -
Inspect before writing.
Always read a value before changing it, so you stay within valid ranges or types.
Example: Full Workflow
Below is a short script that opens Mesh Healer, adjusts the Repair Resolution, and triggers the repair process.
from meshlib import mrviewerpy as mv
# Open the Mesh Repair tab and Mesh Healer tool
mv.uiPressButton(['RibbonTabs', 'Mesh Repair'])
mv.Viewer().skipFrames(1)
mv.uiPressButton(['Ribbon', 'Mesh Healer'])
mv.Viewer().skipFrames(1)# Adjust parameter
val = mv.uiReadValueReal(['Mesh Healer', 'Repair Resolution'])
new_val = val.value * 0.5
mv.uiWriteValueReal(['Mesh Healer', 'Repair Resolution'], new_val)
mv.Viewer().skipFrames(1)# Trigger action
mv.uiPressButton(['Mesh Healer', 'Repair Selected'])
mv.Viewer().skipFrames(1)print("Mesh Healer executed with updated Repair Resolution.")
Summary
You’ve learned how to:
-
List all available controls within a tool
-
Read and modify parameter values
-
Press tool buttons programmatically
-
Synchronize UI updates during automation
These capabilities allow you to replicate any interactive step in MeshInspector through scripting.
In the next article — Working with Geometry — you’ll learn how to load meshes, add them to the scene, select objects, and export results directly using the MeshInspector Python API.