1
Python and Java API / Re: Export model
« on: September 07, 2023, 09:39:11 AM »
Great thank you fixed again.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
def export_model():
### export model
import Metashape
doc = Metashape.app.document
chunk = doc.chunk
model_name = chunk.label
print (chunk)
save_model_folder = Metashape.app.getExistingDirectory("Please select folder to save model in")
print (save_model_folder)
model_save = Metashape.app.getString("Exported model name", model_name)
chunk.exportModel(path = save_model_folder + "/" + "p" + model_save + "_.obj", format = "obj", texture_format = Metashape.ImageFormat.ImageFormatJPEG, save_texture=True)
print ('export obj')
def image_capture():
###export image capture to FSDBTesting/FaceSketches as a jpg
import Metashape
import shutil
current_document = Metashape.app.document
file_path = Path(Metashape.app.document.path)
doc = Metashape.app.document
chunk = doc.chunk
for shape in chunk.shapes:
if not shape.label:
shape.label = shape.group.label
viewpoint = Metashape.app.viewpoint
cx = viewpoint.width
cy = viewpoint.height
cx = 1214
cy = 912
shape_name = chunk.label
shape_name = shape_name[shape_name.find("_")+1:]
save_shape_folder = "G:/Mining/Geology/Favona/FSDBTesting/FaceSketches"
chunk_name = Metashape.app.getString("Enter location name?", shape_name)
capture = Metashape.app.captureModelView( width = cx, height = cy, transparent = (False), hide_items = (False))
#source = Metashape.DataSource.ModelData, mode = Metashape.ModelViewMode.ShadedModelView)
print(capture.height)
capture.save(save_shape_folder + "/" + chunk_name + ".jpg")
def check_string ():
###code for checking the convert obj to str function
import Metashape
doc = Metashape.app.document
chunk = doc.chunk
str(doc)
print (doc)
str(chunk)
print (chunk)