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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python in the context of CMotion

    PYTHON Development
    0
    5
    1.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 25/08/2018 at 07:45, xxxxxxxx wrote:

      I'm digging around some areas of c4d which I've neglected for a while, today its the CMotion object.
      Does anyone know of any examples or use cases for python in the context of CMotion actions? Does it have some predefined parameters/variables? in the help file it just says 
      "You can write, copy, paste, etc.. your Python scripts in this input field. They will be executed automatically by CMotion once the animation is run."

      So I assume there must be some method of addressing relevant / relative cmotion properties?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 27/08/2018 at 09:01, xxxxxxxx wrote:

        Hi Nnenov,

        Regarding your question, you have to define a function called Action.
        Then there is some globals variable available.
        doc: BaseDocument - The document of the current Cmotion Object.
        op: BaseList2D - The object affected by this python Cmotion action.
        time: float - The time in the current document.
        cycle: float - Count of cycle already occurs (for example if the Cmotion Time is set to 30F, it's basically int(CurrentFrame)/int(30))
        pos: float - Current time position in the cycle (from 0.0 to 1.0)
        phase: float - Current value of the phase.
        weight: float - The weight of the python Cmotion action.

        Here a basic example about how to move an object in the X direction.

        import c4d
          
        def Action() :
            maxXValue = 100 * weight
            op.SetRelPos(c4d.Vector(maxXValue,0 ,0) * pos)
        

        If you have any question please let me know!
        Cheers,
        Maxime.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 27/08/2018 at 19:44, xxxxxxxx wrote:

          Hi Maxime,
          Thanks, this is great!
          I was wondering, is there a way to get other objects in the list, for example if op is the object affected by the action, is there a way to relatively (or absolutely) reference another object in the CMotion object manager?
          e.g. I tried op.GetNext() but it doesn't seem to work

          Thanks again!
          Nick

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 28/08/2018 at 03:22, xxxxxxxx wrote:

            Hi,

            I'm afraid it's not possible, op is just a link to the actual object within the scene.
            And there is no way to find the corresponding Cmotion Object, and even if you get the Cmotion Object, CMotion[c4d.ID_CA_WCYCLE_TAG_OBJECTS] is currently not exposed in python and you can't iterate the tree.

            Cheers,
            Maxime.

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 28/08/2018 at 19:42, xxxxxxxx wrote:

              Aw well, I'm not sure what I want to do yet anyway. If I wanted I can just reference the parameters being affected directly from the objects in my scene, I think. need to play with it more
              Thanks!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post