Help with VB scripting

I am trying to write a script that moves object while creating an animation. Does anyone have good script examples that I use as tutorial how to select and move objects, hide and unhide objects, setup animation, etc? I am quite familiar with VB in Excel.
Thanks in advance,

you have to use easing (or tweening) to get a smooth motion of objects. You’ll have to search for that, I’m sure there are VB examples as well.

Stephen -

Does this script help?

Here is one of the popular selection methods:

This guide should help:

This also might help about Animation with Rhinoscript:

Thanks for the reply.
I have seen the first example with the click option to choose the object. My example have more than 30 objects that will move in different paths. I have named all objects and want to use a code to swelect the objects and not a button push. I want to use the object’s Name and not the ID (Name easier to use)

hi Stefan,

To animate the objects in RhinoScript, you don’t need to select them (in fact, its better not to select them).
You just need to reference their IDs to the methods that would control the transformation.

If you have the objects named and want to refer to their names in order to get their IDs in the script, you can use the Rhino.ObjectsByName method. It returns array of objects with given name. If your name is unique, then the first element of the array will be the ID of your object.

Dim idObject : idObject=Rhino.ObjectsByName("YourUniqueName")(0)

Will return that object, and you can work with it in your script animation / transformation methods.

Here is a small sample of how it works:
animation_sample.rvb (1.1 KB)



Thanks Jarek,
Great input…

A question again,
I have created a box and moved it. I want to make it disappear and reappear at the original position again. Any ideas?

Hi Stefan,

There are a few ways to deal with it:

  1. Simplest one: make an InPlace copy of the box before moving it (Rhino.CopyObject) and hide the original (Rhino.HideObject). When move is done, delete the copy and (Rhino.ShowObject) the origina.
    You may need to work with Rhino.EnableRedraw / DisableRedraw to avoid flickering

  2. Turn your object into Block Instance and save its Xform. Then after transforming it you can always reset the block instance xform. May be a bit more complex to script, but if you need a lot of custom animated objects having it set this way could be most beneficial, since your object will remember its own transformations.

  3. Keep track of how much/where you moved it and at the end inverse the movement end and start point and move it back. Probably not the most convenient option.

typing on my phone now, let me know if you need a sample code.


Thanks again Jarek,
I am again stuck with the camera animation setup and are wondering if it is possible to access individual parameters settings from the command prompt? For instance, can I write in VB

Rhino.Command “_SetTurnTableAnimation”, and here the syntax for setting number of frames for instance?

I tried to understand the suggested animation example above but it was very complicated. I would prefer to use the Animation Setup Tools.


Hi Stefan,

To script the animation commands (or any commands in Rhino, especially those that normally show dialog boxes) you need to put “-” before the command to get the command-line only version.

So if you type: Rhino.Command "_-SetTurntableAnimation 20 _Clockwise" etc. you can “script” all the option the command has to offer.

Not sure how complex what you need to do is, and why you prefer to use scripting vs. the built-in commands.
Rhino built in commands only animate the camera. For more complex work you may consider using Bongo which is a dedicated animation tool for Rhino.

I can try to elaborate to write some samples for you to expand on my methods of animating objects above, but ideally I would need to know a bit more of what specifically you are trying to do.
Keep in mind you can also animate the camera via scripting in Rhino, if the built-in tools are not flexible enough.


Hi Jarek,
Thanks for the great support.
I can tell exactly what I am trying to do. I want boxes flying from one point to another with them changing colors (layers) at a specific point. The boxes simultes data packages so that is why I want to have them disappear at the end point and reappear at the starting point.There will be several of these streams of boxes to different points that will have different speeds. That is why I want to circle around the area while recording an animation so the data streams is clearly visable. I want to have a camera view around 45 degrees down towarsd the center with full view all the time of the different streams. I will have text appearing and disappearing explaining what is happening.

Hi Stefan,

Here is a sample script that may help you out to build something similar, specific to what you need.
You can start it in an empty file, the objects and layers will be automatically created.
( since you have yours pre-made, you can use the methods discussed above to reference them).

sample_object_and_camera_animation_01.rvb (3.3 KB)

The code could be cleaner and also for multiple objects the “move” could be wrapped into a reusable function, if needed for many objects, instead of copying it for each, but you should get an idea from this.

If you plan to record animation via image frames, you can script the ViewCaptureToFile command, or just use screen recording software for the script runtime.



Thanks so much Jarek. This helps me a lot.

Could I contact you directly if I have any followup questions?


Hi Stefan, sure, you can send me a PM.