Making animations?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
Hirvonen91
Posts: 10
Joined: Mon Jan 25, 2016 1:02 pm
Location: Joensuu, Finland

Making animations?

Post by Hirvonen91 »

How can you make an animation or mechanism with freecad?

There is that video:
https://www.youtube.com/watch?v=KynMmsLJXV0

There is couple gear rotating, and that guy writes some kind of code.. is that really the only way?
The very same guy have done also a gearbox.. rotating one.

OS: Windows 8
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
CAD makes people boring
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Making animations?

Post by microelly2 »

See my workbench with a lot of demo videos
http://freecadbuch.de/doku.php?id=Animation%20Wokbench

there is no need for programming
all components are parametric.
User avatar
Hirvonen91
Posts: 10
Joined: Mon Jan 25, 2016 1:02 pm
Location: Joensuu, Finland

Re: Making animations?

Post by Hirvonen91 »

microelly2 wrote:See my workbench with a lot of demo videos
http://freecadbuch.de/doku.php?id=Animation%20Wokbench

there is no need for programming
all components are parametric.
Thank you!
I didnt know there is a workbench for that.. i have to learnt that now!

(and i think i should have learn "the engineering" language :oops: .. that could be usefull now. After all you guys did invent almost everything engineering things..)
CAD makes people boring
JMG
Posts: 287
Joined: Wed Dec 25, 2013 9:32 am
Location: Spain
Contact:

Re: Making animations?

Post by JMG »

Hi!

microelly has created a nice workbench for animation, but if you learn how to code them in python directly, you will be able to achieve almost anything you want with FreeCAD (much more than animations).
It's not as hard as it seems, just watch the gear animation video (https://www.youtube.com/watch?v=KynMmsLJXV0) carefully.

Another animation example using python:
http://linuxforanengineer.blogspot.com. ... anism.html

Hope this helps.

Javier.
FreeCAD scripts, animations, experiments and more: http://linuxforanengineer.blogspot.com.es/
Open source CNC hot wire cutter project (NiCr): https://github.com/JMG1/NiCr
Exploded Assembly Workbench: https://github.com/JMG1/ExplodedAssembly
mnc5
Posts: 26
Joined: Tue Nov 07, 2017 7:34 pm

Re: Making animations?

Post by mnc5 »

Hello,

I really like the Animation WB created by microelly2. However, what I'm missing in this WB is the rotation of the objects about arbitrary axis (not only the origin axis).

For example, the rotation shown by the link below consist of three steps. It doesn't seem to be possible to repeat the step #3 in Animation WB as this rotation (step #3) is happening about the tilted axis Z. I would highly appreciate if someone could advise on how this can be done.
https://en.wikipedia.org/wiki/Euler_ang ... uler2a.gif

Thanks in advance.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Making animations?

Post by microelly2 »

I both cases rotator or placer you can change the rotation axis direction and location.

If you want to contrall all 3 euler angles independently there is no direct way at them moment,
but we can do this. there was never before a request.

I use for 3 rotations in assembly an other way
http://freecadbuch.de/doku.php?id=blog: ... r_animiert
phpBB [video]
Sharafatdin
Posts: 3
Joined: Sun Aug 19, 2018 11:37 am

Re: Making animations?

Post by Sharafatdin »

Hi.
I tried to rotate the gears which are shown in this site
https://www.youtube.com/watch?v=KynMmsLJXV0
But my code in python console looks like incorrect
Which is sent below. Is there any synthax error?
from PySide import QtCore
i= 0
def update (i):
global I
App.getDocument." Unnamed2": Body 001 Placement: AppPlacement:AppVector:(0,127.5,0), AppRotation AppVector (0, 0.1, 0), i, AppVector 0,0,0)

i=0.005
timer = QtCore.QTimer ()
timer. timeout.connect (Update)
timer.start (1)
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Making animations?

Post by TheMarkster »

Sharafatdin wrote: Sun Aug 19, 2018 12:01 pm Hi.
I tried to rotate the gears which are shown in this site
https://www.youtube.com/watch?v=KynMmsLJXV0
But my code in python console looks like incorrect
Which is sent below. Is there any synthax error?
from PySide import QtCore
i= 0
def update (i):
global I
App.getDocument." Unnamed2": Body 001 Placement: AppPlacement:AppVector:(0,127.5,0), AppRotation AppVector (0, 0.1, 0), i, AppVector 0,0,0)

i=0.005
timer = QtCore.QTimer ()
timer. timeout.connect (Update)
timer.start (1)
There is a section in the forum for getting help on python scripts. This post is in the section related to help using the FreeCAD Gui.

You should surround code examples using the </> button/icon/tool. This will preserve indentation formatting, which is critical in python. Not preserving the indentation makes it difficult to read because it's impossible to see where a function definition ends without the indentation.

Yes, there are syntax errors.

Python functions are case-sensitive, thus 'update' function must be spelled exactly the same in both places. In other words, Update and update are not considered equal in python.

App.getDocument."Unnamed2" is not correct syntax. I would just use App.ActiveDocument instead unless I needed the Unnamed2 document in particular, in which case: App.getDocument('Unnamed2') is the way to go.

You should create a new macro and use the macro editor rather than entering directly into the python console. That way it is easier to make changes, save them, and run the macro again. I always import FreeCAD first, but I don't know if this is necessarily required in all cases.

You are misusing colons (:) in places where a dot (.) should be used and in places where neither should be used. In other places you are leaving out the dot or the parentheses.

I would separate the placement line something like this:

Code: Select all

object = App.ActiveDocument.getObject('NameOfObject') 
object.Placement=App.Placement(App.Vector(x,y,z),App.Rotation(yaw,pitch,roll),App.Vector(centerX,centerY,centerZ))
In the above (untested) snippet you would replace 'NameOfObject' with the name of your object, e.g. 'Body001'. Parameters x,y,z refer to location of new placement, yaw,pitch,roll to Euler angles (use 0,0,0 if you don't need to rotate), and centerX,centerY,centerZ to the center of the rotation, which can be 0,0,0 if you want to use the origin as the center of rotation or no rotation at all.

If you cannot get it to work you should make a new post in the python scripting forum. Include the full code you are using along with the FreeCAD file you are trying to animate.

Edit: Link to example code: https://forum.freecadweb.org/viewtopic. ... 16#p246494
Sharafatdin
Posts: 3
Joined: Sun Aug 19, 2018 11:37 am

Re: Making animations?

Post by Sharafatdin »

Thanks a lot!
I learned how to create animation :D
Sharafatdin
Posts: 3
Joined: Sun Aug 19, 2018 11:37 am

Re: Making animations?

Post by Sharafatdin »

Hi.

I would like to rotate an object by 45 degrees forward and 45 degrees backward like a lever.
But I do not know how to write the code in python console.
Post Reply