Forum

Author Topic: Python script no longer running in Metashape 1.7.4  (Read 1115 times)

Cyberworld

  • Newbie
  • *
  • Posts: 35
    • View Profile
Python script no longer running in Metashape 1.7.4
« on: August 24, 2021, 12:54:32 PM »
Has anything changed with how Python is handled in Metashape 1.7.4? The script below worked with 1.7.3, but it no longer does.

Code: [Select]
import Metashape

chunk = Metashape.app.document.chunk

for marker in chunk.markers:
for photo in list(marker.projections.keys()):
if not marker.projections[photo].pinned:
marker.projections[photo] = None
print("Projection for "+marker.label + " removed on " + photo.label)

print("Script finished")

Any suggestions?

Cyberworld

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Python script no longer running in Metashape 1.7.4
« Reply #1 on: August 24, 2021, 01:07:13 PM »
Apparently [photo] has been replaced by [camera], and script running now requires for reasons I don't yet understand administrative rights.

The following worked:

Code: [Select]
import Metashape
chunk = Metashape.app.document.chunk
for marker in chunk.markers:
    for camera in list(marker.projections.keys()):
        if not marker.projections[camera].pinned:
            marker.projections[camera] = None

Also the print commands kept causing script failure, but once removed everything worked. All in all consider the issue resolved.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13302
    • View Profile
Re: Python script no longer running in Metashape 1.7.4
« Reply #2 on: August 24, 2021, 02:28:13 PM »
Hello Cyberworld,

The code from your initial post works fine in Metashape 1.7.4 (just copied it to Metashape Console pane for some random project).

photo is just an intermediate variable name in the provided script and can be replaced by any other label in all the occurrences, it wouldn't affect the script.

So, if you have some problems with the script, please provide some additional details - are there any error messages, for example.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Cyberworld

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Python script no longer running in Metashape 1.7.4
« Reply #3 on: August 25, 2021, 09:02:21 AM »
Hi Alexey,

I tried to reproduce the issue today with the previous code and it functions as expected, so I guess some sort of random error. The error it was giving was: "Error: Run script failed"

I did update graphic cards drivers yesterday too, because it was giving a "Can't find tile size" error too, but I'm guessing this was unrelated. In any event, it all works now.