Forum

Author Topic: toolbox dos not work since Update  (Read 5359 times)

gatsri

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
toolbox dos not work since Update
« on: April 08, 2015, 09:00:32 AM »
Hello

I have a personal toolbox (code see bolow)
scince update to 1.1, the toolbox does not work. that means the comands from  the toolbox (Smooth & boundingbox...)

does anyone have the same problem or know what I should do?

****************************************************************************************************************************

import PhotoScan, math

def main():

   doc = PhotoScan.app.document
   chunk = doc.activeChunk
   
   if chunk.model:
      x = PhotoScan.app.getInt("Input number of smoothing steps:", 3)
      chunk.smoothModel(x)
      print("Smoothing by script finished.")
      return 1
   else:
      print("No model. Script aborted.")
      return 0

PhotoScan.app.addMenuItem("ristag/Smooth model", main)   

thanks!


def rotateBb():

   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]**2 + m[0,1]**2 + m[0,2]**2) #scale factor
   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

PhotoScan.app.addMenuItem("ristag/Bounding box to coordinate system", rotateBb)   

« Last Edit: April 08, 2015, 09:55:14 AM by ristag »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15610
    • View Profile
Re: toolbox dos not work since Update
« Reply #1 on: April 21, 2015, 01:37:08 PM »
Hello ristag,

You need to apply the following changes:

doc.activeChunk -> doc.chunk
chunk.transform -> chunk.transform.matrix
Best regards,
Alexey Pasumansky,
Agisoft LLC