PR #2475: Expression syntax extension

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
wmayer
Site Admin
Posts: 14788
Joined: Thu Feb 19, 2009 10:32 am

Re: PR #2475: Expression syntax extension

Postby wmayer » Sat Oct 12, 2019 10:01 pm

The Placement class already had the slerp() method for long time which is now exposed to Python. Here you can see it in action and the difference to the sclerp:

Code: Select all

box1=App.ActiveDocument.Box
box2=App.ActiveDocument.Box001 # a copy of Box

p1=box.Placement
p2=box.Placement
p3=box.Placement

def animate(box1, box2, p1, p2, p3, steps=100):
  for i in range(steps):
    t=(i+1)/steps
    p=p1.sclerp(p2, t)
    box1.Placement=p
    p=p1.slerp(p2, t)
    box2.Placement=p
    Gui.updateGui()
  
  for i in range(steps):
    t=(i+1)/steps
    p=p2.sclerp(p3, t)
    box1.Placement=p
    p=p2.slerp(p3, t)
    box2.Placement=p
    Gui.updateGui()


animate(box1, box2, p1, p2, p3, 1000)