Forum

Author Topic: Script runs differently if I place or take out a doc.save() call in the middle  (Read 1762 times)

reperry

  • Newbie
  • *
  • Posts: 19
    • View Profile
Hello,

I would appreciate your help. I wrote two scripts:
(1) one orients the model and sets the bounding box
(2) the other resets the viewpoint to something nice with the z-axis up (see below)

I found that if I run these consecutively as separate scripts, then both objectives are reached! Unfortunately when I call them from within the same script the second one doesn't happen. The viewpoint stays the same as if (2) never even ran. However, if I include a save function in between the two scripts, then both steps are successfully completed.

I'm including a minimal example below. In place of my script (1) I am doing chunk.updateTransform() which produces the same inconsistency. Please try running the code below on a project with a completed model in a chunk. Then uncomment the doc.save() line. Hopefully you will also see the resulting view depends on doc.save().

Why do I need the doc.save() command for the script to carry out the rotate() function afterwards?

I am using Agisoft PhotoScan Professional Version 1.3.3 build 4827 (64 bit)


Code: [Select]
import PhotoScan

def rotate():
    doc = PhotoScan.app.document
    chunk = doc.chunks[-1]

    T = chunk.transform.matrix
    PhotoScan.app.viewpoint.coo = T.mulp(PhotoScan.Vector([0,0,0]))
    PhotoScan.app.viewpoint.rot = chunk.transform.rotation
    PhotoScan.app.viewpoint.mag = 1000
   
if __name__ == "__main__":

    doc = PhotoScan.app.document
    chunk = doc.chunks[-1]
    chunk.updateTransform()
   
    #doc.save()
    rotate()