Forum

Author Topic: Get "Apply to" list of chunks in batch process  (Read 6788 times)

RoyMudie

  • Newbie
  • *
  • Posts: 7
    • View Profile
Get "Apply to" list of chunks in batch process
« on: February 25, 2020, 07:55:44 PM »
Hi,

I'm writing a couple of python scripts and I've noticed I don't appear to be able to get the list of selected chunks in the "apply to" option when creating a job.

At the moment my script runs differently from the other batch processes (like 'align photos')  because it runs on all chunks, all the time, rather than being able to choose based on this option.

Do you have any boiler plate code I can add to my script to detect "unprocessed chunks" or the list chosen from the "selection"?

Cheers,
Roy

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15472
    • View Profile
Re: Get "Apply to" list of chunks in batch process
« Reply #1 on: February 26, 2020, 08:09:54 PM »
Hello Roy,

Selection status tracking is simple, each chunk has .selected flag (Boolean):
Code: [Select]
chunk.selected
As for the unprocessed list, depending on the planned processing operation you should check the particular chunk contents, for example, if it's required to build mesh, check that chunk.model is not None and etc.
Best regards,
Alexey Pasumansky,
Agisoft LLC

RoyMudie

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get "Apply to" list of chunks in batch process
« Reply #2 on: February 28, 2020, 11:56:03 AM »
Gotcha! Cheers Alexey!

EDIT: Just one thought... how do I know if I should check the "chunk.selected" value? Like if they use the "active chunk" will only the active chunk return "chunk.selected = true"?
« Last Edit: February 28, 2020, 11:58:04 AM by RoyMudie »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15472
    • View Profile
Re: Get "Apply to" list of chunks in batch process
« Reply #3 on: February 28, 2020, 12:59:29 PM »
Hello Roy,

In GUI you can select multiple chunks (via labels) in the Workspace pane, while active chunk can be not selected.

You can give optionality to your script and allow to apply the further processing to the active chunk, all chunks or list of selected chunks. If the list is empty, you can throw the warning message.
Best regards,
Alexey Pasumansky,
Agisoft LLC

RoyMudie

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get "Apply to" list of chunks in batch process
« Reply #4 on: February 28, 2020, 01:27:37 PM »
Hi again Alexy,

I'm having trouble with the selected attribute, it's always returning false when I run it through the batch process...

Code: [Select]
import Metashape

doc = Metashape.app.document

for chunk in doc.chunks:
print(chunk.label + ": " + str(chunk.selected))

Code: [Select]
RunScript: path = d:\metashape\custom-scripts\selectionTest.py
2020-02-28 10:26:46 Landscape Pos1: False
2020-02-28 10:26:46 Landscape Pos2: False
2020-02-28 10:26:46 Landscape Pos3: False
2020-02-28 10:26:46 Portrait Pos3: False
2020-02-28 10:26:46 TextureTest: False
2020-02-28 10:26:46 Alignment Test (not work): False
2020-02-28 10:26:46 Alignemtn Test (should work): False
2020-02-28 10:26:46 Finished processing in 0.018 sec
2020-02-28 10:26:46 Finished batch processing in 0.018 sec (exit code 1)

EDIT: Wait, sorry, I just re-read your post. The chunk.selected value DOES work when I highlight multiple chunks in the workspace (ctrl+click on each one)

But what I want is the ability to use the "apply to -> selection" option from the batch process window.
« Last Edit: February 28, 2020, 01:36:01 PM by RoyMudie »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15472
    • View Profile
Re: Get "Apply to" list of chunks in batch process
« Reply #5 on: February 28, 2020, 02:38:28 PM »
Hello Roy,

Run script operation is Batch mode is not considering "apply to" field (similar to Load and Save project tasks), as they are document-related and not chunk related.
Best regards,
Alexey Pasumansky,
Agisoft LLC