Forum

Author Topic: Run script on start  (Read 26750 times)

arjan

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Run script on start
« Reply #15 on: November 23, 2015, 10:49:50 AM »
same here... need to run a script without user interaction and with access to the Document class.
So far my only option is to use something like AutoIt

xialang2012

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Run script on start
« Reply #16 on: December 31, 2015, 08:44:45 AM »
It works, but is still need some one to click the New Menu to run it.


Hello Nick,

Using autorun scripts you can create custom menus and dialogs that can start customized processing workflow.

So basically, you can define your external script as Python function (via def) and link the custom menu to this function, then put such script to the autorun folder.
Here's short example:
Code: [Select]
import PhotoScan

def test():

print("Testing successfull. Chunk added.")
doc = PhotoScan.app.document
chunk = PhotoScan.Chunk()
chunk.label = "Test chunk"
doc.addChunk(chunk)

return 1

def funct():
doc = PhotoScan.app.document
chunk = doc.chunk

chunk.matchPhotos()
chunk.alignCameras()

print("Done")


label = "New Menu/Test script"
PhotoScan.app.addMenuItem(label, test)

label = "New Menu/Processing script"
PhotoScan.app.addMenuItem(label, funct)


print("New menu added")