Forum

Author Topic: Selecting faces via Python API not visible in viewport?  (Read 3307 times)

Jedidiah Mitchell

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Aura FX Studios
Selecting faces via Python API not visible in viewport?
« on: July 31, 2023, 11:10:35 PM »
When using the Python API to select faces on a model it seems like they are not immediately visible in the viewport. This sample bit of code should select the first 100 faces, but there is no change in the viewer:

Code: [Select]
chunk = Metashape.app.document.chunk
model = chunk.model
for i in range(99):
    model.faces[i].selected = True

The faces are actually selected, which you can verify by running:

Code: [Select]
for i in range(100):
    if model.faces[i].selected:
        print("selected")
    else:
        print("not selected")

But there is nothing visible in the viewport and the lower-left  text doesn't show any selected face count, the "Tools --> Mesh --> Filter by Selection" menu command is greyed out, etc.

If you open up the GUI Gradual Selection tool though, the selected faces immediately show in the viewport -- and then disappear again when the Gradual Selection dialog is closed.

Is there some additional command which needs to be run to "show" selected faces? Or is this a bug?