algorithmic modeling for Rhino
Despite the age of the format, gifs remain a popular and very widely supported way to share small animations. The slider animation function in Grasshopper makes it easy to turn definitions into a sequence of images, but until now you still needed some additional software to actually turn them into playable animations. I used to use VirtualDub for this, but felt it would be nice to be able to do this quicker and without leaving Grasshopper.
The attached component lets you simply specify the filepath of the first frame in a sequence, choose a framerate, then it automatically finds the consecutive images and compiles them into an animated gif.
...and since I'd hate for this to lead to a flood of oversized files - remember, one of the things that makes animated gifs so nice is that they can load and play quickly almost anywhere, but this advantage is lost if the files are too large. When creating your slider animation frames, choose a small resolution, and don't make too many frames. 50 frames at 400x300 pixels is often plenty. If you do want to make something epic and hi-res, stick to a proper modern compressed video format.
Enjoy!
Comment
Hi AJ - do you have your still images saved with names like "name_001.png","name_002.png" and so on?
Also - don't use numbers in the first part of the file name like "animation4name_001.png" or it will get confused trying to find the sequential files.
not working for me
any ideas why?
i get 1kb gif file from the compiled images (from some reason it take a micro sec and say its done)
thnx
It becomes disabled on purpose. To run it again you just have to enable it and it will disable itself again at the end. I prefer this method for scripts I want to run manually over having a boolean input. If you use a boolean toggle you might forget to turn it off, if you use a button it's not guaranteed it will only run once with the input as true.
Awesome Vicent,
I had to look up the references anyway. They are (.net 4.6) WindowsBase.dll, PresentationCore.dll and System.Xaml.dll. For some reason the script remains blocked and there are not changes in the viewport, but generates the gif! Really fast! Thank you.
Based on this idea, to make things even quicker, attached is a scripting component that replaces the slider + animation function and saves a gif directly without generating the intermediate frames (they are only stored in memory).
Rather than adding the code to generate the gif (as in Daniel's script) I used a built in C# class for this, but it's probably worse. First, you can't set a custom delay between frames for some reason (the WinRT analog of this does support it). Second, you'll have reference the required assemblies. If you have the latest .NET framework, hopefully they are in the same folder path as in my computer so you shouldn't have to relink them.
super cool!
Very handy :) Thank you Daniel.
Great!
I had this in my pending tasks. With quality/sample of 1 took me 3 minutes to 9 images. But it's great anyway.
Thank you :)
Welcome to
Grasshopper
© 2024 Created by Scott Davidson. Powered by
You need to be a member of Grasshopper to add comments!