I use following code to animate the camera:
Code: Select all
import sys
import FreeCAD as App, FreeCADGui as Gui, Part, time, sys, math
from PySide2 import QtGui,QtCore
from pivy import coin
class Animation(object):
def __init__(self):
#Gui.runCommand('Std_ViewDockUndockFullscreen',2)
Gui.activeDocument().activeView().setCameraType("Perspective")
self.camera = Gui.ActiveDocument.ActiveView.getCameraNode()
App.Console.PrintMessage('init')
App.ActiveDocument.recompute()
self.timer = QtCore.QTimer()
self.angle = 0.0
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.my_update)
self.timer.start(16) #60 fps
App.Console.PrintMessage('timer started')
def my_update(self):
rotation = coin.SbRotation(coin.SbVec3f(0, 0, 1), self.angle)
self.camera.orientation.setValue(rotation)
Gui.updateGui()
self.angle = self.angle + 0.1
def stop(self):
self.timer.stop()
animation = Animation()
#To stop the animation, type:
#animation.stop()
Code: Select all
Gui.runCommand('Std_ViewDockUndockFullscreen',2)
Is this a bug or by design?
Code: Select all
OS: Ubuntu 21.10 (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.20.
Build type: Release
Branch: unknown
Hash: 12d0974525afe812e81ad623f7d915cb1784118e
Python version: 3.9.6
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.2
Locale: Polish/Poland (pl_PL)