"""Carry the input mesh's material slots onto generated geometry.""" def inherit_material_slots(group, geometry, source): nodes, links = group.nodes, group.links capture = nodes.new("GeometryNodeCaptureAttribute") capture.domain = "POINT" capture.capture_items.clear() capture.capture_items.new("BOOLEAN", "Source") capture.inputs["Source"].default_value = True links.new(source, capture.inputs["Geometry"]) join = nodes.new("GeometryNodeJoinGeometry") links.new(geometry, join.inputs["Geometry"]) links.new(capture.outputs["Geometry"], join.inputs["Geometry"]) material = nodes.new("GeometryNodeSetMaterialIndex") material.inputs["Material Index"].default_value = 0 links.new(join.outputs["Geometry"], material.inputs["Geometry"]) delete = nodes.new("GeometryNodeDeleteGeometry") delete.domain = "POINT" links.new(material.outputs["Geometry"], delete.inputs["Geometry"]) links.new(capture.outputs["Source"], delete.inputs["Selection"]) return delete.outputs["Geometry"]