-
Notifications
You must be signed in to change notification settings - Fork 17
/
Toucher.py
42 lines (32 loc) · 1.07 KB
/
Toucher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import FreeCAD
import Animation
import os
__vers__= '0.2'
__dir__ = os.path.dirname(__file__)
#---------------------------------------------------------------
# Toucher
#---------------------------------------------------------------
class _Toucher(Animation._Actor):
''' to touch object during animation '''
def update(self):
pass
def step(self,now):
self.obj2.target.touch()
for t in self.obj2.targets:
t.touch()
class _ViewProviderToucher(Animation._ViewProviderActor):
def getIcon(self):
return __dir__ + '/icons/animation.png'
def createToucher(name='My_Toucher',target=None,targets=None):
''' createToucher(name,target,targets=None) returns an animation node for one target or a list of targets
target: single object, targets: list of objects
'''
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
obj.addProperty("App::PropertyLink","target","Base","")
obj.addProperty("App::PropertyLinkList","targets","Base","")
obj.target=target
if targets:
obj.targets=targets
_Toucher(obj)
_ViewProviderToucher(obj.ViewObject)
return obj