Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: Florian T. on July 13, 2018, 05:17:28 PM

Title: A way to force non-read-only open? Part 2
Post by: Florian T. on July 13, 2018, 05:17:28 PM
It´s a problem which was discussed one year ago but its still a problem. Wenn i´m running a script which opens a *psx file it´s starting in read-only mode and ask me if i want to modify. Not always but sometimes. So it is interupting the automation script. I use version 1.4.0 and in 1.3.3 the open(path,read_only=False) was implemented which i suposed could handle the problem. It´s still integrated in my scrip but wouldn´t help at all.

If anyone have an idea... I´ll take it.
Title: Re: A way to force non-read-only open? Part 2
Post by: Alexey Pasumansky on July 13, 2018, 09:01:17 PM
Hello Florian,

I can suggest the following workaround:

Code: [Select]
doc = PhotoScan.Document()
doc.open(path, read_only=True)
doc.read_only = False
doc = PhotoScan.app.document
doc.open(path, read_only=False)

Can you please check, if it works as expected?
Title: Re: A way to force non-read-only open? Part 2
Post by: Florian T. on July 16, 2018, 10:25:13 AM
Hi Alexey,

the solution don´t work because every time photoscan opens a file i get the pop up "The project was open in read-only mode. Please make sure you have writing rights on the project folder". So i have to quit every file by clicking on "Ok". But I need a possibility that my script opens 20 or more files and process them one after another without the need to click anything ;-).

I´ve tryed the following:

Code: [Select]
doc.read_only = False
doc.open(path, read_only=False)

At the moment it seems to work for me. Maybe it´s just luck but a test with around 10 files works fine.

Thanks!
Title: Re: A way to force non-read-only open? Part 2
Post by: Alexey Pasumansky on July 16, 2018, 11:39:18 AM
Hello Florian,

Have you tried the suggested solution? As you can see at first the project is not opened in GUI (doc = PhotoScan.Document() not PhotoScan.app.document) and the lock is removed, then it is loaded to GUI. Do you still see the confirmation box when following this approach?
Title: Re: A way to force non-read-only open? Part 2
Post by: Florian T. on July 16, 2018, 12:46:41 PM
Shame on me ... sorry you´re absolutly right.
I used the doc = PhotoScan.app.document as a global variable for both and missed the point you mentioned before.

Now it works fine with your workaround.

Thanks!