Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: PierreB on June 03, 2022, 06:34:48 PM

Title: Re-opening project with chunk
Post by: PierreB on June 03, 2022, 06:34:48 PM
Hi. My workflow is the following:
- python script #1: create project, create chunk, add photos, photo matching and save
- open the project in the GUI and manually add GCP points and save
- python script #2: re-open the project and build the dense cloud
How do I re-open the project with the chunk already created?
Thanks
Title: Re: Re-opening project with chunk
Post by: 3DWinter on June 05, 2022, 09:01:18 AM
I would like to support my interest PierreB's question!
What I have tried to do:

Code: [Select]
doc = Metashape.Document()
doc.open(project_name)
chunk=doc.findChunk(0)

I know the project has four control points, but when I run the following I get nothing.
Code: [Select]
for point in chunk.markers:
    print(point.read)

It is pretty clear I am not reading/loading the chunk correctly.
Thanks
Title: Re: Re-opening project with chunk
Post by: Alexey Pasumansky on June 06, 2022, 03:20:52 PM
Hello!

If you need to open the existing project in the currently opened Metashape instance, you should do the following:

Code: [Select]
doc = Metashape.app.document #currently opened document in actual Metashape window
doc.open(project_name)
Title: Re: Re-opening project with chunk
Post by: PierreB on June 06, 2022, 06:03:52 PM
And what about the chunk? How do I open the existing chunk in the project?
Title: Re: Re-opening project with chunk
Post by: Alexey Pasumansky on June 06, 2022, 07:18:04 PM
Hello Pierre,

Each project always has an active chunk (if there is at least one chunk), which is opened by default, when you load the project.

If you need to change the active chunk, call:
Code: [Select]
doc.chunk = doc.chunks[N] #N - chunk's index in the Workspace pane, starting from 0
Title: Re: Re-opening project with chunk
Post by: PierreB on June 06, 2022, 07:43:30 PM
Thank you Alexey.