Hello, I have recently begun Photoscan scripting and I am having trouble resizing the region through the script.
I have looked around the forums, and learned that in order to convert a vector from geograpic coordinates to the internal chunk coordinate system, I must use the transform matrix (I have no crs, so I don't have to worry about that). I run the following code:
'''
Region resize test
'''
import PhotoScan
doc = PhotoScan.app.document
chunk = doc.activeChunk.copy()
reg = chunk.region
print(reg.size, reg.center)
geo_size = PhotoScan.Vector([2, 2, 2, 1])
geo_cen = PhotoScan.Vector([0, 0, 0, 1])
trans = chunk.transform
inter_size = trans.inv() * geo_size
inter_size.size = 3
inter_cen = trans.inv() * geo_cen
inter_cen.size = 3
print(inter_size, inter_cen)
reg.size = inter_size
reg.center = inter_cen
print(reg.size, reg.center)
chunk.region = reg
PhotoScan.app.document.activeChunk = chunk.copy()
print(PhotoScan.app.document.activeChunk.region.size, PhotoScan.app.document.activeChunk.region.center)
and get the following output:
Vector([9.5782843002474, 6.393577422917392, 4.753930638638135]) Vector([-0.11697801952045438, -3.7556900242420745, 10.212026733309294])
Vector([-9.311766117668544, -12.952894025375354, 13.232803759861106]) Vector([0.15980629407120994, -0.3897937990467731, 13.243165534310934])
Vector([-9.311766117668544, -12.952894025375354, 13.232803759861106]) Vector([0.15980629407120994, -0.3897937990467731, 13.243165534310934])
Vector([9.5782843002474, 6.393577422917392, 4.753930638638135]) Vector([-0.11697801952045438, -3.7556900242420745, 10.212026733309294])
As you can see, the vectors for size and center seem to be correctly converted, and set in the region variable. However, for some reason,
PhotoScan.app.document.activeChunk = chunk.copy()
does not change the activeChunk's region, and nor does:
PhotoScan.app.document.activeChunk = chunk
or
PhotoScan.app.document.activeChunk.region = reg
Thank you for your help