Forum

Author Topic: Can I automatically re-order chunks in a project?  (Read 1164 times)

ashalota

  • Jr. Member
  • **
  • Posts: 93
  • Forest orthomosaics, long transects (300m agl)
    • View Profile
    • NASA: G-LiHT (Public orthomosaics)
Can I automatically re-order chunks in a project?
« on: June 26, 2019, 06:57:12 PM »
I've written the following function:

Code: [Select]
def sortChunks(doc):
    """Sorts chunks in alphabetical order by title. Chunks beginning with "Merged" will be placed at the bottom."""

    chunkDict = {}
    mergeDict = {}
    for chunk in doc.chunks:
        if chunk.label.startswith('Merged'):
            mergeDict[chunk.label] = chunk
        else:
            chunkDict[chunk.label] = chunk
   
    labels = sorted(chunkDict.keys())
    mergeLabels = sorted(mergeDict.keys())
   
    newChunks = []
    for label in labels:
        newChunks.append(chunkDict[label])
    for label in mergeLabels:
        newChunks.append(mergeDict[label])
   
    for i in range(len(doc.chunks)-1):
        print(doc.chunks[i].label + ' -> ' + newChunks[i].label)
        doc.chunks[i] = newChunks[i]  #NO EFFECT!
    doc.save()

Unfortunately the assignment

Code: [Select]
doc.chunks[i] = newChunks[i]

has no effect. Is there any way to reorder chunks in a script?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14816
    • View Profile
Re: Can I automatically re-order chunks in a project?
« Reply #1 on: July 02, 2019, 07:02:07 PM »
Hello ashalota,

Unfortunately, the order of the chunks currently cannot be modified via Python, but we'll try to implement such functionality in one of the upcoming updates.

The order of the chunk in the project is defined by the unique chunk.key value that cannot be modified now.
Best regards,
Alexey Pasumansky,
Agisoft LLC