Hello kylemryan,
I recommend to put the cameras to the camera groups in the original chunks before merging and name the groups according to the chunk labels, thus it will be easier to navigate workspace after chunk merging operation, as the groups will be preserved.
And here is the script that allows to add the chunk's label as a prefix to the camera label (either to selected chunks or to all the chunks in the active project):
from PySide2 import QtCore, QtGui, QtWidgets
import Metashape
class RenameCameras(QtWidgets.QDialog):
def __init__ (self, parent):
QtWidgets.QDialog.__init__(self, parent)
self.setWindowTitle("Add chunk label to camera names")
self.btnQuit = QtWidgets.QPushButton("&Exit")
self.btnP1 = QtWidgets.QPushButton("&Rename")
self.pBar = QtWidgets.QProgressBar()
self.pBar.setTextVisible(False)
self.radioBtn_all = QtWidgets.QRadioButton("Apply to entire workspace")
self.radioBtn_sel = QtWidgets.QRadioButton("Apply to selected chunks")
self.radioBtn_all.setChecked(True)
self.radioBtn_sel.setChecked(False)
layout = QtWidgets.QGridLayout() #creating layout
layout.addWidget(self.radioBtn_all, 0, 1)
layout.addWidget(self.radioBtn_sel, 1, 1)
layout.addWidget(self.pBar, 2, 0)
layout.addWidget(self.btnP1, 2, 1)
layout.addWidget(self.btnQuit, 2, 2)
self.setLayout(layout)
proc_chunks = lambda : self.proc_all()
QtCore.QObject.connect(self.btnP1, QtCore.SIGNAL("clicked()"), proc_chunks)
QtCore.QObject.connect(self.btnQuit, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()"))
self.exec()
def proc_all(self):
global app
print ("\nScript started...")
self.pBar.setMinimum(0)
self.pBar.setMaximum(0)
self.btnP1.setDisabled(True)
self.btnQuit.setDisabled(True)
self.radioBtn_sel.setDisabled(True)
self.radioBtn_all.setDisabled(True)
selected = False
if self.radioBtn_sel.isChecked():
selected = True
elif self.radioBtn_all.isChecked():
selected = False
doc = Metashape.app.document
for chunk in doc.chunks:
if selected and not chunk.selected:
print("Chunk '" + chunk.label + "' is not selected. Skipping...")
continue
print("Processing chunk " + chunk.label + "...")
app.processEvents()
for camera in chunk.cameras:
if camera.type != Metashape.Camera.Type.Regular:
continue #skipping animation cameras
camera.label = chunk.label + "_" + camera.label
print("..done!")
app.processEvents()
self.pBar.setMaximum(100)
self.pBar.setValue(100)
self.btnP1.setDisabled(False)
self.btnQuit.setDisabled(False)
self.radioBtn_sel.setDisabled(False)
self.radioBtn_all.setDisabled(False)
app.processEvents()
print("Script finished.\n")
return 1
def rename_cameras():
global app
app = QtWidgets.QApplication.instance()
parent = app.activeWindow()
dlg = RenameCameras(parent)
Metashape.app.addMenuItem("Custom menu/Add chunk label to camera names", rename_cameras)