Wow, that is (almost) exactly what I am after! Amazing.
The only thing is the rotation does not seem to export correctly.
My cam has a value of
R X: 90.277 R Y: 0.366 R Z: -116.01
Your script returns
90.3086 1-26.0081 270.5014
Not sure how to troubleshoot this to make it work but I will look it over.
EDIT: Looking at the code and result, it appears to be saving the HPB order rather than XYZ.
I managed to get it to work (I think) by adding some code to the rotation_rad
rotation_rad = c4d.utils.MatrixToHPB(obj_matrix,c4d.ROTATIONORDER_XYZGLOBAL)
Massive thanks for even bothering to take a look!
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 = c4d.storage.SaveDialog(c4d.FILESELECTTYPE_ANYTHING, 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 = obj_matrix.off
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, %s'%(name,
position.x,
position.y,
position.z,
rotation_deg.x,
rotation_deg.y,
rotation_deg.z)
csv_file.write(line + '\n')
obj = Walker(obj)
csv_file.close()
if __name__=='__main__':
main()