name camera is not defined

Asked by blairon

Hello,
I just started to use the tutorial.
when trying to run the bingle_runnable.py I have the following error message
 camera.setLookAt(self.lookAt)
NameError: name 'camera' is not defined

I have checked the POVsnaps.py file but I don't see any mistake.
Can somebody help me
thanks

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
Dion Weatherley
Solved:
Last query:
Last reply:
Revision history for this message
Best Dion Weatherley (d-weatherley) said :
#1

Hi Blairon,

It is possible the error is due to an indentation problem in your POVsnaps.py script. Python is very particular about having the correct number of indentation spaces but it can be difficult sometimes to identify when a space is missing.

The snapshot() subroutine should be written this way:

def snapshot(self):
   pkg = povray
   Scene = pkg.Scene()

   plist = self.sim.getParticleList()
   for pp in plist:
      povsphere = pkg.Sphere(pp.getPosn(), pp.getRadius())
      povsphere.apply(pkg.Colors.Red)
      Scene.add(povsphere)

   camera = Scene.getCamera()
   camera.setLookAt(self.lookAt)
   camera.setPosn(self.camPosn)
   camera.setZoom(self.zoomFactor)

   fname = "snap_%.4d.png" % (self.count)
   Scene.render(
      offScreen=True,
      interactive=False,
      fileName=fname,
      size=self.imageSize
   )

Try replacing your snapshot() subroutine in POVsnaps.py with this one and see how you go.

Cheers,

Dion.

Revision history for this message
blairon (jean-marie-blairon) said :
#2

OK
thanks a lot
J.M.

Revision history for this message
blairon (jean-marie-blairon) said :
#3

Thanks Dion Weatherley, that solved my question.