def __init__(self, constraintSystem):
		self.constraintSystem = constraintSystem
		self.form = FreeCADGui.PySideUic.loadUi( ':/assembly2/ui/degreesOfFreedomAnimation.ui' )
		self.form.setWindowIcon(QtGui.QIcon( ':/assembly2/icons/degreesOfFreedomAnimation.svg' ) )
		self.form.groupBox_DOF.setTitle('%i Degrees-of-freedom:' % len(constraintSystem.degreesOfFreedom))
		
		FreeCAD.DOF=constraintSystem.degreesOfFreedom
		
		for i, d in enumerate(constraintSystem.degreesOfFreedom):
			item = QtGui.QListWidgetItem('%i. %s' % (i+1, str(d)[1:-1].replace('DegreeOfFreedom ','')), self.form.listWidget_DOF)
			if i == 0: item.setSelected(True)



# hack start create animation tools
		import Animation
		from say import *
		import Placer
		for i, d in enumerate(constraintSystem.degreesOfFreedom):
			sayErr(i)
			say(d.__class__.__name__)
			say(d.objName)
			p=Placer.createPlacer("DOF_" + str(i) +"_")
			p.ViewObject.Visibility=False
			p.target=FreeCAD.ActiveDocument.getObject(d.objName)
			if d.__class__.__name__ == 'LinearMotionDegreeOfFreedom':

				p.x='x0+x1*(time-0.5)*50'
				p.y='y0+y1*(time-0.5)*50'
				p.z='z0+z1*(time-0.5)*50'

				b=p.target.Placement.Base
				p.x0=b.x
				p.y0=b.y
				p.z0=b.z
				p.x1=d.directionVector[0]
				p.y1=d.directionVector[1]
				p.z1=d.directionVector[2]
				p.RotAxis=p.target.Placement.Rotation.Axis
				p.arc=str(p.target.Placement.Rotation.Angle*180/np.pi)

			if d.__class__.__name__ == 'AxisRotationDegreeOfFreedom':
				p.prePlacement=p.target.Placement
				
				
				p.arc='360*time'
				p.x='0'
				p.y='0'
				p.z='0'
				p.arc0=d.getValue()*180/np.pi
				p.RotAxis=(d.axis[0],d.axis[1],d.axis[2])
				p.RotCenter=p.target.Placement.Base
# hack end



		self.form.pushButton_animateSelected.clicked.connect(self.animateSelected)
		self.form.pushButton_animateAll.clicked.connect(self.animateAll)
		self.form.pushButton_set_as_default.clicked.connect( self.setDefaults )
		self.setIntialValues()
Пример #2
0
 def testPlacer(self):
     FreeCAD.Console.PrintLog('Checking Placer...\n')
     b = App.activeDocument().addObject("Part::Box", "Box")
     r = Placer.createPlacer("BoxPlacer", b)
     m = createManager()
     m.intervall = 10
     m.sleeptime = 0.01
     m.addObject(r)
     m.Proxy.run()
     self.failUnless(
         isequal(b.Placement.Rotation.Angle, 0.5654866776461628),
         "Rotation error")
     self.failUnless(isequal(b.Placement.Base.x, 21.45749434738491),
                     "Move error")
Пример #3
0
reload(Placer)

import Speeder
reload(Speeder)

# d=App.newDocument("Unbenannt")
r = Draft.makeRectangle(length=200,
                        height=100.,
                        placement=pl,
                        face=True,
                        support=None)
r.Placement.Base.z = -0.01

b = App.activeDocument().addObject("Part::Box", "PingPong Box")
b.ViewObject.ShapeColor = (1.0, .0, .0)
r = Placer.createPlacer("BoxPlacer ping pong", b)
r.arc = "0"

s = Speeder.createSpeeder("Speeder Ping Pong")
s.mode = 'ping pong'
s.target = r

b1 = App.activeDocument().addObject("Part::Box", "Reverse moving Box")
b1.ViewObject.ShapeColor = (1.0, 1.0, .0)
r1 = Placer.createPlacer("BoxPlacer reverse", b1)
r1.arc = "0"
r1.y = "10"
s1 = Speeder.createSpeeder("Speeder backward")
s1.mode = 'backward'
s1.target = r1
Пример #4
0
    def setupContextMenu(self, obj, menu):
        return


if __name__ == '__main__':

    App.ActiveDocument.addObject("Part::Box", "Box")
    App.ActiveDocument.addObject("Part::Box", "Box")
    App.ActiveDocument.addObject("Part::Box", "Box")
    App.ActiveDocument.addObject("Part::Box", "Box")
    App.ActiveDocument.addObject("Part::Cone", "Cone")

    import Placer

    s1 = Placer.createPlacer("B1")
    s1.target = App.ActiveDocument.Box001

    s2 = Placer.createPlacer("B2")
    s2.target = App.ActiveDocument.Box002
    s2.y = "10"

    s3 = Placer.createPlacer("B3")
    s3.target = App.ActiveDocument.Box003
    s3.y = "20"

    c = createCombiner("cmb")
    c.source = App.ActiveDocument.Cone

    c.trafo = "source.Radius1.Value"
    c.target = s1
Пример #5
0
App.setActiveDocument("Unnamed")
App.ActiveDocument=App.getDocument("Unnamed")
Gui.ActiveDocument=Gui.getDocument("Unnamed")
import Animation
Animation.createManager()

App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.addObject("Part::Cone","Cone")


import Placer

s1=Placer.createPlacer("B1")
s1.target=App.ActiveDocument.Box001

s2=Placer.createPlacer("B2")
s2.target=App.ActiveDocument.Box002
s2.y="10"

s3=Placer.createPlacer("B3")
s3.target=App.ActiveDocument.Box003
s3.y="20"


import Diagram
c=Diagram.createDiagram("dia","0.200*time","0.2*(0.01*time-0.5)**2","10+time+1","-10*time")
c.source=s1
c.trafo="source.Placement.Rotation.Angle"
Пример #6
0
# testcase manager and placer


def isequal(a,b):
	return abs(a-b)<1e-6


import Animation
from Animation import *
reload(Animation)

import Placer
reload(Placer)

d=App.newDocument("Unbenannt")
b=App.activeDocument().addObject("Part::Box","Box")


r=Placer.createPlacer("BoxPlacer",b)

m=createManager()
m.intervall = 10
m.sleeptime = 0.01
m.addObject(r)
m.Proxy.run()

assert(isequal(b.Placement.Rotation.Angle,0.5654866776461628))
assert(isequal(b.Placement.Base.x,21.45749434738491))

#App.closeDocument("Unbenannt")
Пример #7
0
V.ViewObject.PointSize = 10
V.ViewObject.PointColor = (1.0, .0, .0)

# slaves
s = App.ActiveDocument.addObject("Part::Sphere", "Sphere")
b = App.ActiveDocument.addObject("Part::Box", "Box")
t = App.ActiveDocument.addObject("Part::Torus", "Torus")

s.ViewObject.ShapeColor = (1.0, 1.0, .0)
b.ViewObject.ShapeColor = (.0, 1.0, 1.0)
t.ViewObject.ShapeColor = (1.0, .0, 1.0)

# ACTOR #

# move the sphere relative (10,-5,0) to the control point
p = Placer.createPlacer("Sphere Mover", s)
p.src = V
p.x = "sx+10"
p.y = "sy-5"

# rotate the cube with rotation arc 20*sx along the default z-axis
p2 = Placer.createPlacer("Box Rotator", b)
p2.src = V
p2.x = "-50"
p2.y = "-5"
p2.arc = "20*sx"

# rotate the donat with rotation arc 10*sy  along the x-axis
p3 = Placer.createPlacer("Torus Rotator", t)
p3.src = V
p3.x = "50"
Пример #8
0
FreeCAD.newDocument("Unbenannt")

box = FreeCAD.activeDocument().addObject("Part::Box", "Static")
box.Height = 40
box.Length = 100

box2 = FreeCAD.activeDocument().addObject("Part::Box", "Animated")
box2.Placement.Base = FreeCAD.Vector(.0, .0, 0.)

toucher = Toucher.createToucher("Force the Common", box)

#
# Example: track the vertexes of a changing fusion
#

placer = Placer.createPlacer("Box Placer", box2)
placer.x = "100*time-10"
placer.y = " -5  if time< 0.5 else 7"
placer.z = "5+30*(0.5-time)**2"
placer.arc = "0"
placer.time = 0

manager = Animation.createManager()
manager.intervall = 100
manager.sleeptime = 0.0

fuse = App.activeDocument().addObject("Part::MultiFuse", "Fusion")
fuse.Shapes = [box, box2]
fuse.ViewObject.ShapeColor = (1.0, 1.0, .5)
fuse.ViewObject.Transparency = 70
Пример #9
0
import Placer

reload(Placer)

import Tracker

reload(Tracker)

import Trackreader

reload(Trackreader)

d = App.newDocument("Unbenannt")
b = App.activeDocument().addObject("Part::Box", "Box")

r = Placer.createPlacer("BoxPlacer", b)

t = Tracker.createTracker("BoxTracker", r, "/tmp/tracker")

m = Animation.createManager()

m.intervall = 100
m.sleeptime = 0.01
m.addObject(r)
m.addObject(t)
m.Proxy.run()

path = t.ViewObject.Proxy.showpath()

import Trackreader
Пример #10
0
        w = Draft.makeWire(points)
        w.ViewObject.LineWidth = 1.0
        w.ViewObject.LineColor = (.0, 1.0, .0)

    for y in range(101):
        points = [
            FreeCAD.Vector(0, 2 * y, -0.1),
            FreeCAD.Vector(200, 2 * y, -0.1)
        ]
        w = Draft.makeWire(points)
        w.ViewObject.LineWidth = 1.0
        w.ViewObject.LineColor = (1.0, .0, .0)

b = App.activeDocument().addObject("Part::Box", "Box")
b.ViewObject.ShapeColor = (1.0, .0, .0)
r = Placer.createPlacer("Placer", b)
r.arc = "0"

s = Speeder.createSpeeder("Speeder Ping Pong")
s.mode = 'ping pong'
s.m = 50

s.target = r

s = Speeder.createSpeeder("Speeder Fade")
s.mode = 'fade'
s.b = 0.3
s.c = 0.8
s.m = 50
s.g = 0.5
s.target = r
Пример #11
0
# pather testcase

import Animation,Draft, Pather, Placer

box=App.ActiveDocument.addObject("Part::Box","Box")
points=[FreeCAD.Vector(22.0,6.0,0.0),
	FreeCAD.Vector(8.,60.5,0.0),
	FreeCAD.Vector(-20,-27.3,0.0),
	FreeCAD.Vector(16.32,-41.3,0.0)]
bspline=Draft.makeBSpline(points)

pa=Pather.createPather('BSpline as Path')
pa.src=bspline

pl=Placer.createPlacer('Placer for Box',box)
pl.x='sx-5'
pl.y='sy-5'
pl.arc='0'
pl.src=pa

m=Animation.createManager()
m.addObject(pa)
m.addObject(pl)

m.Proxy.run()
Пример #12
0

def isequal(a, b):
    return abs(a - b) < 1e-6


import FreeCAD
import Animation
import Placer

FreeCAD.newDocument("Unbenannt")

# zwei zu animierende Objekte erzeugen und
# ihrer Plazierer festlegen
b = FreeCAD.activeDocument().addObject("Part::Torus", "Torus")
r = Placer.createPlacer("Torus Placer", b)
r.x = '100'
r.RotAxis = FreeCAD.Vector(1.0, 0, 0)

b2 = FreeCAD.activeDocument().addObject("Part::Box", "Box")
k = Placer.createPlacer("Box Placer", b2)

m = Animation.createManager()
m.intervall = 100
m.sleeptime = 0.01

# die beiden Plazierer durch den Manager verwalten lassen
m.addObject(r)
m.addObject(k)

# den Manager starten
Пример #13
0
V.ViewObject.PointSize=10
V.ViewObject.PointColor=(1.0,.0,.0)

# slaves
s=App.ActiveDocument.addObject("Part::Sphere","Sphere")
b=App.ActiveDocument.addObject("Part::Box","Box")
t=App.ActiveDocument.addObject("Part::Torus","Torus")

s.ViewObject.ShapeColor=(1.0,1.0,.0)
b.ViewObject.ShapeColor=(.0,1.0,1.0)
t.ViewObject.ShapeColor=(1.0,.0,1.0)

# ACTOR #

# move the sphere relative (10,-5,0) to the control point
p=Placer.createPlacer("Sphere Mover",s)
p.src=V
p.x="sx+10"
p.y="sy-5"

# rotate the cube with rotation arc 20*sx along the default z-axis
p2=Placer.createPlacer("Box Rotator",b)
p2.src=V
p2.x="-50"
p2.y="-5"
p2.arc="20*sx"

# rotate the donat with rotation arc 10*sy  along the x-axis
p3=Placer.createPlacer("Torus Rotator",t)
p3.src=V
p3.x="50"
Пример #14
0
		points=[FreeCAD.Vector(2*x,-200,-0.1),FreeCAD.Vector(2*x,200,-0.1)]
		w=Draft.makeWire(points)
		w.ViewObject.LineWidth=1.0
		w.ViewObject.LineColor=(.0,1.0,.0)

	for y in range(101):
		points=[FreeCAD.Vector(0,2*y,-0.1),FreeCAD.Vector(200,2*y,-0.1)]
		w=Draft.makeWire(points)
		w.ViewObject.LineWidth=1.0
		w.ViewObject.LineColor=(1.0,.0,.0)



b=App.activeDocument().addObject("Part::Box","Box")
b.ViewObject.ShapeColor=(1.0,.0,.0)
r=Placer.createPlacer("Placer",b)
r.arc="0"

s=Speeder.createSpeeder("Speeder Ping Pong")
s.mode='ping pong'
s.m=50

s.target=r


s=Speeder.createSpeeder("Speeder Fade")
s.mode='fade'
s.b=0.3
s.c=0.8
s.m=50
s.g=0.5
Пример #15
0
import Placer
reload(Placer)

import Speeder
reload(Speeder)



# d=App.newDocument("Unbenannt")
r=Draft.makeRectangle(length=200,height=100.,placement=pl,face=True,support=None)
r.Placement.Base.z=-0.01


b=App.activeDocument().addObject("Part::Box","PingPong Box")
b.ViewObject.ShapeColor=(1.0,.0,.0)
r=Placer.createPlacer("BoxPlacer ping pong",b)
r.arc="0"

s=Speeder.createSpeeder("Speeder Ping Pong")
s.mode='ping pong'
s.target=r


b1=App.activeDocument().addObject("Part::Box","Reverse moving Box")
b1.ViewObject.ShapeColor=(1.0,1.0,.0)
r1=Placer.createPlacer("BoxPlacer reverse",b1)
r1.arc="0"
r1.y="10"
s1=Speeder.createSpeeder("Speeder backward")
s1.mode='backward'
s1.target=r1
Пример #16
0
FreeCAD.newDocument("Unbenannt")

box=FreeCAD.activeDocument().addObject("Part::Box","Static")
box.Height=40
box.Length=100

box2=FreeCAD.activeDocument().addObject("Part::Box","Animated")
box2.Placement.Base=FreeCAD.Vector(.0,.0,0.)

toucher=Toucher.createToucher("Force the Common",box)

#
# Example: track the vertexes of a changing fusion
#

placer=Placer.createPlacer("Box Placer",box2)
placer.x="100*time-10"
placer.y=" -5  if time< 0.5 else 7"
placer.z="5+30*(0.5-time)**2"
placer.arc="0"
placer.time=0

manager=Animation.createManager()
manager.intervall = 100
manager.sleeptime = 0.0

fuse=App.activeDocument().addObject("Part::MultiFuse","Fusion")
fuse.Shapes = [box,box2]
fuse.ViewObject.ShapeColor=(1.0,1.0,.5)
fuse.ViewObject.Transparency=70