Forum

Author Topic: Proper method to close project via python API  (Read 1576 times)

ashalota

  • Jr. Member
  • **
  • Posts: 93
  • Forest orthomosaics, long transects (300m agl)
    • View Profile
    • NASA: G-LiHT (Public orthomosaics)
Proper method to close project via python API
« on: January 11, 2021, 05:49:19 PM »
I've noticed I end up with a 'read-only' lock on my projects some times after I have made adjustments through my python script.

What is the correct way to close the document so it goes away when I am done working on it in python? I don't see a "close" method anywhere in the API. My best guess is to just open a blank Metashape project when I am done with my current project?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13908
    • View Profile
Re: Proper method to close project via python API
« Reply #1 on: January 13, 2021, 09:02:50 PM »
Hello ashalota,

Can you please describe the common workflow that you are using, when the "read-only" lock appears? Do you perform multiple operations with the projects using scripting in the same Metashape instance?
Best regards,
Alexey Pasumansky,
Agisoft LLC

ashalota

  • Jr. Member
  • **
  • Posts: 93
  • Forest orthomosaics, long transects (300m agl)
    • View Profile
    • NASA: G-LiHT (Public orthomosaics)
Re: Proper method to close project via python API
« Reply #2 on: January 13, 2021, 09:38:31 PM »
I believe I may have solved this issue by running "Metashape.Document()" when I am done with my process.

The issue occurred because I had been opening a project, working on it, and then transferring it to another computer. The other computer then never received any information that I ultimately closed the project. I am now making sure to "close" the project within my script by running Metashape.Document() before sending it to the other computer.

3DWinter

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: Proper method to close project via python API
« Reply #3 on: March 18, 2021, 10:15:31 AM »
Same here. After every time I ran my code, I would open the new project and it would be as read-only, which caused Metashape to be unstable!
I was looking for a close method for the document in my code, something like doc.close() but didn't find it in the API manual.

There is doc.open(project_name), and doc.save(), why not doc.close()?

Your solution of Metashape.Document(), does solve the problem. It enables me to open the project right after the code ran. I just don't know if that is what Agisoft expected us to do, or is there a more elegant way.
thanks