Created
January 28, 2024 12:30
-
-
Save kwahoo2/659590f81d36f77e3e543308ff157e9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FreeCAD as App, FreeCADGui as Gui, time | |
from PySide2 import QtGui,QtCore | |
class Animation(object): | |
def __init__(self): | |
App.Console.PrintMessage("init \n") | |
App.ActiveDocument.recompute() | |
self.timer = QtCore.QTimer() | |
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.my_update) | |
self.timer.start(100) #100ms for step, adjust to performance of the PC | |
self.an = 1 | |
def my_update(self): | |
self.an = self.an + 1 | |
App.ActiveDocument.getObject('Fixed').Rotation = self.an | |
Gui.runCommand('Assembly_SolveAssembly',0) | |
#Uncomment line below to save pics | |
#Gui.ActiveDocument.ActiveView.saveImage('/directory/to/write/pics/' +str(self.an)+'.png',1280,720,'Current') | |
print(str(self.an) + "\n") | |
def stop(self): | |
self.timer.stop() | |
animation = Animation() | |
#To stop the animation, type: | |
#animation.stop() | |
#To encode a video | |
#ffmpeg -framerate 25 -i %00d.png -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment