Hello Seboon,

Please check this one:

`import PhotoScan`

doc = PhotoScan.app.document

chunk = doc.chunk

crs = chunk.crs

region = chunk.region

T = chunk.transform.matrix

m = PhotoScan.Vector([10E+10, 10E+10, 10E+10])

M = -m

for point in chunk.model.vertices:

coord = T.mulp(point.coord)

coord = chunk.crs.project(coord)

for i in range(3):

m[i] = min(m[i], coord[i])

M[i] = max(M[i], coord[i])

center = (M + m) / 2.

side1g = crs.unproject(M) - crs.unproject(PhotoScan.Vector([m.x, M.y, M.z]))

side2g = crs.unproject(M) - crs.unproject(PhotoScan.Vector([M.x, m.y, M.z]))

side3g = crs.unproject(M) - crs.unproject(PhotoScan.Vector([M.x, M.y, m.z]))

size = PhotoScan.Vector([side2g.norm() , side1g.norm(), side3g.norm()])

region.center = T.inv().mulp(crs.unproject(center))

region.size = size * (1 / T.scale())

v_t = T.mulp(region.center)

R = crs.localframe(v_t) * T

region.rot = R.rotation().t()

chunk.region = region

print("Script finished.")