Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. Vibz
    V
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    Vibz

    @Vibz

    0
    Reputation
    5
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Vibz Unfollow Follow

    Latest posts made by Vibz

    • RE: Camera animation to Text file?

      This is a great start - will defiantly be using this to get closer to the desired end result 🙂
      Thanks so much Manuel for your help!

      posted in Cinema 4D SDK
      V
      Vibz
    • Camera animation to Text file?

      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 = 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'%(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()
      
      posted in Cinema 4D SDK r20 python
      V
      Vibz