Forum

Author Topic: Saving all chunks  (Read 2603 times)

excalibur

  • Newbie
  • *
  • Posts: 14
    • View Profile
Saving all chunks
« on: May 18, 2015, 01:08:44 PM »
Hi guys,

Is it possible to save (script) all chunks into separate photoscan files.

example: from 1 file with 10 chunks -> 10 files including only 1 chunk?

thank you

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13295
    • View Profile
Re: Saving all chunks
« Reply #1 on: May 18, 2015, 02:28:09 PM »
Hello exalibrur,

You can make a copy of each chunk to the temporary variable, for example, temp_chunk = active_chunk.copy(), then create new document: doc2 = PhotoScan.Document() and then add the chunk:
doc2.addChunk(temp_chunk)
doc2.save(path)
Best regards,
Alexey Pasumansky,
Agisoft LLC

picare

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Saving all chunks
« Reply #2 on: September 28, 2021, 10:33:27 AM »
Hi,
The command doc.addChunk does not accept a chunk anymore into its parameters.
Is it another way to save all chunks into separate projects without reloading the full project each time?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13295
    • View Profile
Re: Saving all chunks
« Reply #3 on: September 28, 2021, 02:11:50 PM »
Hello Pierre,

you can use optional chunks argument in doc.save() function, in case you need to save a new project using only a few chunks from original project.

The following example should save each chunk from the source project under a different name:
Code: [Select]
doc = Metashape.app.document
for i in range(len(doc.chunks)):
   doc.save(path = "project_chunk_" + str(i) + ".psx", chunks = [doc.chunks[i]])
Best regards,
Alexey Pasumansky,
Agisoft LLC

picare

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Saving all chunks
« Reply #4 on: September 28, 2021, 05:46:10 PM »
A very clean method. thanks!  :)