Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: ashalota on January 11, 2021, 05:49:19 PM

Title: Proper method to close project via python API
Post by: ashalota 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?
Title: Re: Proper method to close project via python API
Post by: Alexey Pasumansky 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?
Title: Re: Proper method to close project via python API
Post by: ashalota 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.
Title: Re: Proper method to close project via python API
Post by: 3DWinter 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