Hey all,
We have been using the same scripts for a few years now with no issues, including the update to Metashape. Since we recently updated to version 1.6, the scripts no longer work. We get an error that reads "Module 'Metashape' has no attribute '****' "
I tried this in version 1.6.0 and 1.6.1 and get the same error. After reverting to 1.5.4 (The last version we had) there is no issues.
I will attach one of this scripts here. The message with this reads specificaly "Module 'Metashape' has no attribute 'Mediumquality' "
Is this an error with our python install? Or will we need to revamp the scripts for version 1.6 and up?
import PhotoScan
import os
doc = PhotoScan.app.document
def get_save():
path = PhotoScan.app.getSaveFileName("Save project as")
try:
doc.save(path)
except RuntimeError:
PhotoScan.app.messageBox("Can't Save Project")
def check_save():
if doc.path is not "":
print("save exists")
else:
print("no save file")
get_save()
def align(chunk):
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy,
generic_preselection=True,
reference_preselection=False,
keypoint_limit=55000,
tiepoint_limit=5000
)
chunk.alignCameras()
def align_all():
for chunk in doc.chunks:
align(chunk)
doc.save()
def duplicate(chunk):
name = chunk.label
new = chunk.copy()
new.label = "3D_PDF_{}".format(name)
def duplicate_all(export=True):
for chunk in doc.chunks:
# Max
name = chunk.label
chunk.label = "Max_{}".format(name)
# Rhino
rhino = chunk.copy()
rhino.label = "Rhino_{}".format(name)
rhino.decimateModel(1500000)
rhino.buildUV(mapping=PhotoScan.GenericMapping)
rhino.buildTexture(blending=PhotoScan.MosaicBlending,
size=4096)
if export is True:
ext = ".wrl"
file = format_file(ext, rhino)
rhino.exportModel(file)
# PDF
pdf = chunk.copy()
pdf.label = "3D_PDF_{}".format(name)
pdf.decimateModel(100000)
pdf.buildUV(mapping=PhotoScan.GenericMapping)
pdf.buildTexture(blending=PhotoScan.MosaicBlending,
size=4096)
if export is True:
ext = ".pdf"
file = format_file(ext, pdf)
pdf.exportModel(file)
doc.save()
def process(chunk):
chunk.buildDepthMaps(quality=PhotoScan.MediumQuality,
filter=PhotoScan.AggressiveFiltering)
chunk.buildDenseCloud()
chunk.buildModel(surface=PhotoScan.Arbitrary,
interpolation=PhotoScan.EnabledInterpolation,
face_count=0)
chunk.buildUV(mapping=PhotoScan.GenericMapping)
chunk.buildTexture(blending=PhotoScan.MosaicBlending,
size=4096)
doc.save()
def process_all():
for chunk in doc.chunks:
process(chunk)
def decimate_pdf(chunk):
chunk.decimateModel(100000)
def get_folder(chunk):
pic = chunk.cameras[0].photo.path
path = os.path.dirname(pic)
return path
def format_file(ext, chunk):
path = get_folder(chunk)
file = "{}/{}{}".format(path, chunk.label, ext)
return file
def main():
check_save()
align_all()
if __name__ == "__main__":
main()