Hi everyone,
I have no experience whatsoever with coding, but I'm trying to adapt this scrypt so it can be used in version 1.1.0:
#rotates model bounding box in accordance of coordinate system for active chunk
#bounding box size is kept
#compatibility: Agisoft PhotoScan Professional 0.9.0
import PhotoScan
import math
doc = PhotoScan.app.document
chunk = doc.activeChunk
T = chunk.transform
v = PhotoScan.Vector( [0,0,0,1] )
v_t = T * v
v_t.size = 3
m = chunk.crs.localframe(v_t)
m = m * T
s = math.sqrt(m[0,0]*m[0,0] + m[0,1]*m[0,1] + m[0,2]*m[0,2]) #scale factor
# S = PhotoScan.Matrix( [[s, 0, 0], [0, s, 0], [0, 0, s]] ) #scale matrix
R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]])
R = R * (1. / s)
reg = chunk.region
reg.rot = R.t()
chunk.region = reg
So far I've made it into this: import PhotoScan
import math
doc = PhotoScan.app.document
chunk = doc.chunk
T = chunk.transform.matrix
v_t = T * PhotoScan.Vector( [0,0,0,1] )
v_t.size = 3
m = chunk.crs.localframe(v_t)
m = m * T
s = math.sqrt(m[0,0]*m[0,0] + m[0,1]*m[0,1] + m[0,2]*m[0,2]) #scale factor
# S = PhotoScan.Matrix( [[s, 0, 0], [0, s, 0], [0, 0, s]] ) #scale matrix
R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]])
R = R * (1. / s)
reg = chunk.region
reg.rot = R.t()
chunk.region = reg
However I get the following error message:
line 16, in <module>
m = chunk.crs.localframe(v_t)
AttributeError: 'NoneType' object has no attribute 'localframe'
Any tips on how to overcome this issue?
Thanks in advance,
Thomas