FORUMS: list search recent posts

[SOLVED] Camera animation to Text file

COW Forums : Maxon Cinema 4D

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Viktor Brittsjö
[SOLVED] Camera animation to Text file
on Aug 12, 2019 at 10:52:33 am
Last Edited By Viktor Brittsjö on Aug 13, 2019 at 1:21:03 pm

Hey everyone.

I'm trying to find a way to export moving camera data (rotation and position) from cinema 4d to a csv file.
I have found a python script on how to get this on ONE single frame. I'll insert the code I found bellow.
This code outputs position (x, y and z) and rotation degrees (x, y and z) on one row in different columns, which is perfect.

My question is how to expand the code to make the script look through each frame in the timeline and not only one frame,
giving each frame it's own row in the csv doc.

My lack of python knowledge hinders me from getting closer to my goals. All help is appreciated!

import c4d
#Welcome to the world of Python

def Walker(obj):
if not obj: return

elif obj.GetDown():
return obj.GetDown()
while obj.GetUp() and not obj.GetNext():
obj = obj.GetUp()
return obj.GetNext()

def main():
file =, title='Save csv file as', force_suffix='csv')
csv_file = open(file, 'w')
obj = doc.GetFirstObject()
while obj:
if obj.GetType() == 5103:
name = obj.GetName()
obj_matrix = obj.GetMg()
position =
rotation_rad = c4d.utils.MatrixToHPB(obj_matrix,c4d.ROTATIONORDER_XYZGLOBAL)
rotation_deg = c4d.Vector(c4d.utils.Deg(rotation_rad.x), c4d.utils.Deg(rotation_rad.y), c4d.utils.Deg(rotation_rad.z))
line = '%s, %s, %s, %s, %s, %s'%(position.x,
csv_file.write(line + '\n')
obj = Walker(obj)

if __name__=='__main__':

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved