baking script vs baking plugins [SOLVED]

On 27/11/2014 at 03:45, xxxxxxxx wrote:

Hi guys,

I just moved from 3ds max to c4d and so I m moving from maxscript to python at the same time.

I am trying to write a script to automate baking on selected object, to be more specific creating a null and matching his position/rotation/scale to the object and keying the null on every frame.

In maxscript I would have done a for loop looking like that (baking the object named 'objectToBake' for a 250 frames long scene) :
obj=point()   //create null

for i=0 to 250 do
sliderTime = i
obj.addkey (this won t be that line but it s just the concept)

Then in c4d I did the same thing in python. So within the object to bake selected I run this:
import c4d
from c4d import gui
#Welcome to the world of Python




if not posTrack:


for i in range(0,91) :
    c4d.EventAdd()     // here is my issue, can t update during a loop


And basically it works only on the first frame.
From what I read it s all because script in c4d are singlethread and so the positions don t update during the loop even though I update the time slider position during the loop.

So now I m trying to do it through a plugin hoping now my positions will be updated during the loop.
Is a plugin the good way to do it ?

I also want to create an user inteface to select the objects I want to bake and all that stuff. And then I was wondering if this go with the plugin as well and if a plugin is the only way to do it.

Hope all this is not to confusing but I m a bit lost with what script are doing and what plugins are for in c4d.

Would be great if you can let me know if I m in the good direction or not.
To make it very simple, I just want to know what is the way to run commands in a loop and having everything updated at each loop iteration.

Thank you !

On 27/11/2014 at 04:03, xxxxxxxx wrote:


you might have a look at this thread, there is a basic bake script,

There is a sync message that will update your scene like:


You can use a script even if you want to use a dialog.
A async dialog plugin might be a good choice, too.

Best wishes

On 28/11/2014 at 00:38, xxxxxxxx wrote:

Hello and welcome,

setting the current frame of a document is not as simple as:


You can use SetTime() to set the current frame of a document. However this will not animate the scene. To get the state of an object in a certain frame you have to animate the scene since the state of an object may depend on other objects like deformers, effectors etc. To animate the scene use ExecutePasses():

  for i in range(0,90) :  
      time = c4d.BaseTime(i,fps)  

best wishes,

On 28/11/2014 at 02:49, xxxxxxxx wrote:

Thanks Sebastian for the detailed explanation!
Always great to see how you straighten things out!

That´s what the

def SetCurrentFr(FR, doc) :

function in my script does.

Just a small additional note.
After some experiments with baking mograph, dynamics, etc.
I recommend to use the

                  key = curve.AddKey(CurrTime)['key']  

instead of

              key = curve.AddKey(CurrTime)['key']  
              key.SetValue(curve, val)  

for translation keys.

Best wishes

On 05/12/2014 at 08:22, xxxxxxxx wrote:

Hello had,

was your question answered?

best wishes,