In case someone is interested, I have added a small animation controller class in mnesarco utils to help in creating animation macros.realthunder wrote: ↑Wed Jan 27, 2021 9:59 pm For animation, you can consult the attached script in this post.
Example animation macro:
Code: Select all
import FreeCAD as App, FreeCADGui as Gui
import freecad.mnesarco.asm3.animation as anim
class Anim:
def prepare(self):
self.cstr = App.ActiveDocument.getObject('Constraint')
self.cstr.LockAngle = True
def cleanup(self):
self.cstr.LockAngle = False
def run(self, frame):
self.cstr.Angle = frame * 5
ctrl = anim.Asm3AnimationController("Assembly", Anim(), frames=72)
ctrl.animate(fps=10)
- prepare: runs before animation code
- run: is the animation loop, (uses cache technique from the original animation.py script)
- cleanup: runs after animation
code in run method can change more than one constraint, so it is pretty easy to create compound animations.
Code for reference: https://github.com/mnesarco/FreeCAD_Uti ... imation.py
I will add async timer support, so the camera can be moved while the animation is running (as i do with Asm4 animations)