Animated Chebychev Lambda Mechanism Sketch

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
atzensepp
Posts: 100
Joined: Tue Feb 24, 2015 9:37 pm

Animated Chebychev Lambda Mechanism Sketch

Post by atzensepp »

For a small demonstration project I created an animation of the famous and ingenious Chebycev Lambda Machine.
"The Chebyshev's Lambda Mechanism[1] is a four-bar mechanism that converts rotational motion to approximate straight-line motion with approximate constant velocity" (from http://en.wikipedia.org/wiki/Chebyshev% ... _Mechanism )

I am always wondering how one can get such ideas.

Code: Select all

#Macro Animate Chebychev's Lambda Mechanism
#  http://en.wikipedia.org/wiki/Chebyshev%27s_Lambda_Mechanism
#
import FreeCAD
from FreeCAD import Base, Draft
import Part, Mesh, PartGui, sys, math, collections

import time

sketch = App.ActiveDocument.Sketch
for rev in range(0,2):
   wire = []
   for theta in range(0,360,5):
      sketch.setDatum(13,App.Units.Quantity(str(theta) + ' deg'))
      p=sketch.Shape.Vertexes[4].Point
      wire.append(FreeCAD.Vector(p[0],p[1],p[2])) #

      App.ActiveDocument.recompute()
 # Update display
      Gui.updateGui()
      time.sleep(0.02)
   theWire = Draft.makeWire(wire,closed=True,face=False,support=None)  
   Part.show(theWire.Shape)
#Macro End:   
Attachments
Chebyshev-Lambda-Machine.fcstd
(3.11 KiB) Downloaded 66 times
chebychev-lambda.png
chebychev-lambda.png (22.69 KiB) Viewed 1704 times
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Animated Chebychev Lambda Mechanism Sketch

Post by cox »

Hi

I am getting :

Code: Select all

File "/home/kjetil/.FreeCAD/tt.FCMacro", line 17, in <module>
    wire.append(FreeCAD.Vector(p[0],p[1],p[2])) #
<type 'exceptions.NameError'>: name 'wire' is not defined
when trying to run this.

Any Ide what it could be?
Need help? Feel free to ask, but please read the guidelines first
atzensepp
Posts: 100
Joined: Tue Feb 24, 2015 9:37 pm

Re: Animated Chebychev Lambda Mechanism Sketch

Post by atzensepp »

I have uploaded the Macro just in case there is a copy and paste error.
Attachments
anim-macro.tgz
(560 Bytes) Downloaded 105 times
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Animated Chebychev Lambda Mechanism Sketch

Post by cox »

I must have messed up something on my end I guess, found wire = [] was swire = [] :oops:

I could not find that in your code.

Nice work
Need help? Feel free to ask, but please read the guidelines first
Post Reply