Skip to content

Scripting API

Repair

from ArtisanPlugin.Scripting import ManufacturingApi as manufacturing

A design straight off the modelling stage is rarely printable: open surfaces, flipped normals, overlapping solids. AutomaticRepair is the ArtisanAutomaticRepair tool run headless — it closes gaps, fixes normals and produces one watertight mesh ready for the printer. Rhino 8 or higher only (it uses ShrinkWrap).

Usage

r = manufacturing.AutomaticRepair(objectIds = None, precision = 0, deleteOriginal = False)
ParameterDefaultMeaning
objectIdsNone = current selectionObjects to repair — solids, surfaces or meshes. Gems are skipped automatically, like the tool
precision0 = the tool’s configured default (typically 0.025)Repair precision in mm. Smaller = more faithful and slower
deleteOriginalFalseTrue removes the source objects after the repair

The call starts from your saved Automatic Repair defaults when they exist, exactly like the command; a precision greater than 0 overrides the saved value.

The result

The repaired mesh is added to the document on the last user layer with the wax colour from your settings, same as the tool’s Accept button. The source objects stay in place unless deleteOriginal = True. Because the call adds (and possibly deletes) objects, wrap it in a Transaction so the whole repair undoes in one step.

AutomaticRepair returns a RepairResult:

FieldTypeMeaning
MeshIdGuidThe repaired mesh added to the document
IsClosedboolTrue = watertight, printable
ShellsintNumber of separate shells in the result
NakedEdgesintRemaining open edges — 0 is what you want

Don’t assume success means printable: check IsClosed (or run Verify) before sending the mesh downstream.

Validation that throws:

  • Rhino older than 8: "Automatic Repair requires Rhino 8 or higher."
  • Nothing usable after the gem filter: "Nothing to repair: select (or pass) at least one non-gem solid, surface or mesh." — a selection made only of gems fails, it is not silently ignored.
  • The computation fails: "This geometry could not be repaired. Try a different precision."
from ArtisanPlugin.Scripting import ManufacturingApi as manufacturing, Transaction

with Transaction.Begin("Automatic repair"):
    r = manufacturing.AutomaticRepair(deleteOriginal = True)
    print(f"Closed: {r.IsClosed}, shells: {r.Shells}, naked edges: {r.NakedEdges}")