Forum

Author Topic: Failed to show results using windows to run script  (Read 4242 times)

Zeying

  • Newbie
  • *
  • Posts: 20
    • View Profile
Failed to show results using windows to run script
« on: February 16, 2023, 09:23:30 AM »
Dear Concerned.
I tried using windows command line to run a script which I tested works fine in GUI by "Tools->Run Script"
The script is simply to open a existing project file as such:
Code: [Select]
doc=PhotoScan.app.document
chunk = doc.addChunk()
doc.open(path="D:\Agisoft\ShekPik.psx")

So I typed this in Windows command line to run this python file:
Code: [Select]
C:\Program Files\Agisoft\Metashape Pro>metashape.exe -r "C:\Users\Insight\AppData\Local\Agisoft\Metashape Pro\scripts\temp.py"

Windows return:
Code: [Select]
Agisoft Metashape Professional Version: 1.8.4 build 14856 (64 bit)
Platform: Windows
CPU: AMD EPYC 7402 24-Core Processor
CPU family: 23 model: 49 signature: 830F10h
RAM: 255.9 GB
LoadProject: path = D:\Agisoft\ShekPik.psx
loaded project in 0.191 sec

As a result project is not opened. Anyone can help me on this?
Thanks in advance!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15232
    • View Profile
Re: Failed to show results using windows to run script
« Reply #1 on: February 16, 2023, 07:56:36 PM »
Hello Zeying,

In the scripts run in headless mode you cannot use Metashape.app.document call, as it is related to the project opened in GUI.

If you need to create and save new project use:
Code: [Select]
doc = Metashape.Document()
doc.save(path)
chunk = doc.addChunk()
doc.save()

To open existing project use:
Code: [Select]
doc = Metashape.Document()
doc.open(path)
chunk = doc.addChunk()
doc.save()

Also I recommend to use either "slash" symbols in the path "/" or double "back slash" - "\\" to avoid possible issues.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Zeying

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Failed to show results using windows to run script
« Reply #2 on: March 07, 2023, 09:18:12 AM »
Dear Alexey
Thank you for your reply.
I've managed to do so but I'm curious why add.Chunk? doesn't it give you an extra empty chunk that you don't need?

Thx
Zeying

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15232
    • View Profile
Re: Failed to show results using windows to run script
« Reply #3 on: March 07, 2023, 01:58:22 PM »
Hello Zeying,

I've just gave an example how to create a new project and add a new chunk to it and how to open the existing project and add a new chunk to it. If you are working with the existing project that already have any chunks with the data, then, of course, you can continue working with the active chunk, for example: chunk = doc.chunk
Best regards,
Alexey Pasumansky,
Agisoft LLC

Zeying

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Failed to show results using windows to run script
« Reply #4 on: March 08, 2023, 10:20:25 AM »
thanks a lot!