Hello J.K.,
That is an expected behavior for the case, when the mesh model is imported to the empty chunk.
Below you can find the script that allows to import georeferenced mesh model (in projected coordinate system) to the empty chunk. So you just need to run the script (it will add a custom menu item), then point to it the path to OBJ or DXF model and select the coordinate system. Then the script will automatically assign the coordinate system to the chunk and properly import the model to it.
import Metashape
#-791116.062500 X -1149216.000000 Y 543.011 m
def import_mesh_obj_dxf():
doc = Metashape.app.document
chunk = doc.chunk
path = Metashape.app.getOpenFileName("Select mesh file for import:", filter = "DXF files (*.dxf);; OBJ files (*.obj)")
if not path:
print("Nothing to import, script aborted.")
return 0
crs = Metashape.app.getCoordinateSystem("Specify CRS for imported mesh:", Metashape.CoordinateSystem("EPSG::5514"))
if not crs:
print("Invalid CRS, script aborted.")
return 0
if path.upper().endswith("DXF"):
file = open(path, "rt")
lines = file.readlines()
readX=False
readY=False
readZ=False
x = 0
y = 0
z = 0
readN = 0
count = 0
for line in lines:
if line.strip() == "10":
readX = True
continue
elif line.strip() == "20":
readY = True
continue
elif line.strip() == "30":
readZ = True
continue
if readX and not x:
x = float(line.strip())
readN += 1
continue
elif readY and not y:
y = float(line.strip())
readN += 1
continue
elif readZ and not z:
z = float(line.strip())
readN += 1
continue
if readN >= 3:
break
file.close()
if readN < 3:
print("Not enough data, cannot import")
return 0
chunk.crs = crs
chunk.transform.matrix = Metashape.Matrix.Translation(crs.unproject((x, y, z)))
chunk.importModel(path, Metashape.ModelFormatDXF, crs)
elif path.upper().endswith("OBJ"):
file = open(path, "rt")
lines = file.readlines()
for line in lines:
if line[0] != "v":
continue
params = line.strip().split(" ")
break
x = float(params[1])
y = float(params[2])
z = float(params[3])
file.close()
chunk.crs = crs
chunk.transform.matrix = Metashape.Matrix.Translation(crs.unproject((x, y, z)))
chunk.importModel(path, Metashape.ModelFormatOBJ, crs)
else:
print("Unsupported mesh format")
return 0
chunk.resetRegion()
print("Script finished")
#doc.save()
return 1
label = "Custom menu/Import mesh from OBJ or DXF"
Metashape.app.addMenuItem(label, import_mesh_obj_dxf)
print("To execute this script press {}".format(label))
But note that this version of the script doesn't support offsets (shift) input, if you need that, let me know.