Forum

Author Topic: Script from archive doesn't save project  (Read 1458 times)

Yoann Courtois

  • Sr. Member
  • ****
  • Posts: 315
  • Engineer in Geodesy, Cartography and Surveying
    • View Profile
Script from archive doesn't save project
« on: March 19, 2020, 07:11:17 PM »
Hey !

Something really crazy appeared in my script.
Indeed, sometimes I have to start from old project which has been stored as an archive (*.psz)
So I open the archive file and then save it into a project file (*.psx) in order to work inside.

But after the following piece of code, no more savings are effective (using doc.save())
But ... how ?!?!

Code: [Select]
           __project_path = "directory/project.psx"
           __archive_path = "directory/archive.psz"

            doc = Metashape.app.document
            doc.open(path=__archive_path, ignore_lock=True)
            chunk = doc.chunk
            doc.save(path=__project_path)

Regards
--
Yoann COURTOIS
R&D Engineer in photogrammetric process and mobile application
Lyon, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14004
    • View Profile
Re: Script from archive doesn't save project
« Reply #1 on: March 19, 2020, 07:27:42 PM »
Hello Yoann,

Which version of Metashape are you using?

And what happens after you use doc.save() after provided block of code? Which changes are applied to the project before that and how?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Yoann Courtois

  • Sr. Member
  • ****
  • Posts: 315
  • Engineer in Geodesy, Cartography and Surveying
    • View Profile
Re: Script from archive doesn't save project
« Reply #2 on: March 20, 2020, 07:03:54 PM »
Hello Alexey,

Our scripts currently run on Metashape 1.5.0
We are planning to update towards 1.6 soon but during last year not many updates were looking indipensable for us.

doc.save() seems to save the project, but actually not. Or it is saving but without any update (then are done ground classification, dem and ortho building, etc.)

I guess the crazyest thing in this story, is that I actually succeed to fix the problem, with the following code ...

Code: [Select]
           __project_path = "directory/project.psx"
           __archive_path = "directory/archive.psz"

            doc = Metashape.app.document
            doc.open(path=__archive_path, ignore_lock=True)
            doc.save(path=__project_path)
            doc.clear()

            doc = Metashape.app.document
            doc.open(path=__project_path, ignore_lock=True)
            chunk = doc.chunk
            doc.save()

It's strange, and this code looks horrible, but it works... An idea about where is the difference ?

Regards

--
Yoann COURTOIS
R&D Engineer in photogrammetric process and mobile application
Lyon, FRANCE
--

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14004
    • View Profile
Re: Script from archive doesn't save project
« Reply #3 on: March 20, 2020, 09:31:37 PM »
Hello Yoann,

Does it work without re-loading the project?
Code: [Select]
           __project_path = "directory/project.psx"
           __archive_path = "directory/archive.psz"

            doc = Metashape.app.document
            doc.open(path=__archive_path, ignore_lock=True)
            doc.save(path=__project_path)

            #any changes applied to the project
            doc.save()
Best regards,
Alexey Pasumansky,
Agisoft LLC