set_mesh_material_id_in_region
Stamp a MaterialID onto every triangle in a local region of a dynamic mesh, useful after booleans fuse pieces when polygroups cannot address them separately.
Instructions
Stamp a MaterialID onto every triangle inside a region, via the engine's SelectMeshElements* family + SetMaterialIDForMeshSelection. Use this when polygroups are not usable — after a boolean, appended pieces are fused and set_polygroup_material_id cannot address them separately. Coordinates are LOCAL to the dynamic mesh, not world. Preview any region with select_mesh_triangles before painting: a region that selects 0 triangles still returns success.
Returns: { actor_name, material_id, region, triangles_selected: int, max_material_id_after: int, distinct_material_ids_after: int, applied: bool }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| center | No | Local [x,y,z] centre. Used by box/sphere, and as the plane origin. | |
| extent | No | Local [x,y,z] HALF-size in cm. Required by region='box'. | |
| invert | No | Invert the spatial selection (default false). | |
| normal | No | [x,y,z] direction. Plane normal for region='plane', facing direction for 'normal_angle'. Default [0,0,1]. | |
| radius | No | Radius in cm. Required by region='sphere'. | |
| region | No | 'all' (default) | 'box' | 'sphere' | 'plane' | 'normal_angle' | 'material_id' | 'polygroup' | 'connected_component' (one physical PIECE, by the island index that get_mesh_components_detail reports). | |
| actor_name | Yes | Label or name of the target DynamicMeshActor. | |
| material_id | No | MaterialID to write (>= 0). | |
| polygroup_id | No | Polygroup to select when region='polygroup'. | |
| max_angle_deg | No | Max angle from normal in degrees for region='normal_angle' (default 15). | |
| component_index | No | Island index when region='connected_component'. Get it from get_mesh_components_detail, which reports each piece's size and bounding box. | |
| polygroup_layer | No | Optional extended polygroup layer index for region='polygroup'. | |
| source_material_id | No | The MaterialID to SELECT when region='material_id'. Separate from material_id, which is the one being written, so 'repaint 1 as 2' is expressible. | |
| min_triangle_points | No | How many of a triangle's 3 points must be inside for it to count, 1-3 (default 3 = fully contained). Only used by the spatial regions. |