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. martijnlambada
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    martijnlambada

    @martijnlambada

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

    martijnlambada Unfollow Follow

    Latest posts made by martijnlambada

    • RE: Keyframing a property using python.

      Hi Manual,

      Thanks for your help! Next time I will use the 'ask question' when posting a question.
      You code does exactly what I need, much appreciated!

      Cheers,
      Martijn

      posted in Cinema 4D SDK
      M
      martijnlambada
    • Keyframing a property using python.

      Hi all,

      I’m trying to make a little script that takes all selected cameras and puts them in a (newly created) stage object (one camera per frame).

      Super useful if you want to render out stills on a render farm that doesn’t support takes.

      I’ve got almost everything working:

      • Getting the selected cameras and putting them in an array.
      • Creating a stage object
      • Looping through the array and putting the cameras into the camera slot of the stage object.
      • Moving 1 frame forward

      The two things I’m struggling with:

      1. How to key frame the camera slot properly so it actually creates the animation (different camera per frame). I’m using the mydoc.RecordKey() property but how do I find out which id (?) the camera property has?
      2. Ideally I want to catch errors when someone selects something other than a camera. Is there an easy way to catch that error? Should I loop through the array and check the individual elements?

      Who can point me into the right direction?

      Your help is much appreciated.

      Best regards,
      Martijn

      script:

      import c4d, math
      from c4d import gui
      
      # This is a little script that puts the selected cameras into a stage object with keyframes
      
      
      # Main function
      def main():
          # Clear Console for easy debugging
          c4d.CallCommand(13957, 13957)
      
          # Get selected cameras
          obj = doc.GetActiveObjects(1)
      
          # Check if selected objects are cameras, if not pop-up error
          #code should come here
      
      
          # Go to Start of timeline
          c4d.CallCommand(12501)
      
          #create stage object
          stage = c4d.BaseObject(c4d.Ostage)
          doc.InsertObject(stage)
      
          # Get active document
          mydoc = c4d.documents.GetActiveDocument()
      
          # Loop through the array of cameras & put selected cameras in stage object
          for x in obj:
              mytime = mydoc.GetTime()
              myfps = mydoc.GetFps() # define prject fps
              myframe = mytime.GetFrame(myfps) #get current frame
              print(myframe) # print frame number
      
              stage[c4d.STAGEOBJECT_CLINK] = x # put camera camera slot of stage object
      
              #set keyframe How??
              #mydoc.RecordKey(stage,[c4d.ID_BASEOBJECT_REL_ROTATION,c4d.VECTOR_X]) #Add the keyframe to Rotation X successfully
              mydoc.RecordKey(stage, 1)
      
      
      
              # Go to next key frame
              c4d.CallCommand(12414)
      
          c4d.EventAdd() #update
      
      
      
      # Execute main()
      if __name__=='__main__':
          main()
      
      posted in Cinema 4D SDK
      M
      martijnlambada