Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: excalibur on May 18, 2015, 01:08:44 PM

Title: Saving all chunks
Post by: excalibur 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
Title: Re: Saving all chunks
Post by: Alexey Pasumansky 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)
Title: Re: Saving all chunks
Post by: picare 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?
Title: Re: Saving all chunks
Post by: Alexey Pasumansky 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]])
Title: Re: Saving all chunks
Post by: picare on September 28, 2021, 05:46:10 PM
A very clean method. thanks!  :)