Hi all,
i was able to modify the code that includes comparing face vertices z values to shape Zmin and if all face vertices have z less than minimum then face is selected and removed:
chunk = Metashape.app.document.chunk
shapes = [shape for shape in chunk.shapes if shape.group.label == 'Const']
T = chunk.transform.matrix
task = Metashape.Tasks.DuplicateAsset()
task.asset_type = Metashape.ModelData
task.clip_to_boundary = True
task.asset_key = chunk.models[0].key
for shape in shapes:
zmin = 1e9
for v in shape.vertices:
if v.z < zmin:
zmin = v.z
shape.boundary_type = Metashape.Shape.OuterBoundary
task.apply(chunk)
shape.boundary_type = Metashape.Shape.NoBoundary
chunk.models[-1].label = shape.label
model = chunk.models[-1]
for f in model.faces:
zval = [(chunk.shapes.crs.project(T.mulp(model.vertices[f.vertices[0]].coord))).z,(chunk.shapes.crs.project(T.mulp(model.vertices[f.vertices[1]].coord))).z,(chunk.shapes.crs.project(T.mulp(model.vertices[f.vertices[2]].coord))).z]
zval.sort()
if zval[-1] < zmin:
f.selected = True
model.removeSelection()
print('Roof {} Area3D: {:.3f} m2 Area2D: {:.3f} m2'.format(model.label,model.area(),shape.area()))
Following capture shows result of running code on 3 roof shapes.
Hope this can be helpful,