Skip to content

Instantly share code, notes, and snippets.

@kwahoo2
Created February 4, 2023 12:06
Show Gist options
  • Save kwahoo2/a432a8724530406728b091baa8fe981c to your computer and use it in GitHub Desktop.
Save kwahoo2/a432a8724530406728b091baa8fe981c to your computer and use it in GitHub Desktop.
# This script aniamtes "Box" attached to an curve with MapPathParameter
# This script aniamtes "Box" attached to an curve with MapPathParameter
import FreeCAD as App, FreeCADGui as Gui, Part, time
from PySide2 import QtGui,QtCore
class Animation(object):
def __init__(self):
App.Console.PrintMessage('Animation has started\n')
App.ActiveDocument.recompute()
self.timer = QtCore.QTimer()
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.my_update)
self.timer.start(100) #step every 0.1s (100 ms)
self.val = 0.0 #start
self.step = 0.01 #step value
self.end = 1.0 #end value
def my_update(self):
App.ActiveDocument.getObject('Box').MapPathParameter = self.val #move the box on the path
self.val = self.val + self.step #
App.ActiveDocument.recompute()
if self.val > self.end:
# self.timer.stop() #uncomment to stop animation after reaching end value
self.val = 0.0
def stop(self):
self.timer.stop()
App.Console.PrintMessage('Animation stopped\n')
animation = Animation()
#to stop type animation.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment