-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path02_LoadPhotosInNewChunk.py
35 lines (27 loc) · 1.11 KB
/
02_LoadPhotosInNewChunk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This script created by Joseph Aaron Campbell - 03/2021
""" Set up Working Environment """
# import Metashape library module
import Metashape
# create a reference to the current project via Document Class
doc = Metashape.app.document
""" Prompt User to Select Images """
# create array/list of images via user input gui
images = Metashape.app.getOpenFileNames()
""" Create New Chunk and Rename It """
# create new chunk to avoid changing any currently existing chunks
newChunk = doc.addChunk()
# set new chunk as active chunk
Metashape.app.document.chunk = newChunk
# set a new reference for the new chunk
activeChunk = newChunk
"""Rename the New Active Chunk"""
# get full list of chunks
chunkList = doc.chunks
# rename the new chunk,but only if it exists
# also add the integer position in chunks list
# this ensures each time the script runs each chunk has a unique name.
if activeChunk in chunkList:
activeChunk.label = 'pyChunk_' + str(len(chunkList)-1)
""" Add User Selected Photos to Active Chunk"""
# add images to chunk from array/list created earlier
activeChunk.addPhotos(images)