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. Daguna
    3. Posts
    D
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 4
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by Daguna

    • RE: Timeline commands ran via Python script does not have same result

      Marvelous @Dunhou, thanks yet again!!

      Here's the final script in case someone else has use for it:

      from typing import Optional
      import c4d
      
      doc: c4d.documents.BaseDocument  # The active document
      op: Optional[c4d.BaseObject]  # The active object, None if unselected
      
      def main():
      
          # Retrieves BaseTime of frame 5, 20
          start = 0
          end = 1
          if c4d.CheckIsRunning(c4d.CHECKISRUNNING_ANIMATIONRUNNING) == True:
              c4d.CallCommand(12412) # Play Forwards
      
          # Loops through the frames
          for frame in range(start, end + 1):
      
              # Changes the time of the document
              doc.SetTime(c4d.BaseTime(frame, doc.GetFps()))
      
              # Updates timeline
              c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
      
              # Redraws the viewport and regenerate the cache object
              c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_STATICBREAK)
      
          # Pushes an update event to Cinema 4D
          c4d.EventAdd(c4d.EVENT_ANIMATE)
      
      if __name__ == '__main__':
          main()
      
      posted in Cinema 4D SDK
      D
      Daguna
    • RE: Timeline commands ran via Python script does not have same result

      Endless thanks @Dunhou, your last version works perfectly!

      Final thing, I realized it needs an if statement to check if the playhead is playing forwards, and if so stop it. Command 12412 seems to be a "toggle" value, and I have tried to figure it out myself but without success.. Any chance you can help me with this last piece of the puzzle aswell?

      My current attempt, that always seems to trigger:

          if c4d.CallCommand(12412) == True:
              c4d.CallCommand(12412) # Play Forwards
              return
      
      posted in Cinema 4D SDK
      D
      Daguna
    • RE: Timeline commands ran via Python script does not have same result

      @i_mazlov Thank you very much for taking the time out to help me with this! Please excuse the late reply, I had neglected to activate email notifications 🙄

      I have now tried the solution you provided but it gives the same result unfortunately.

      Maybe it should be mentioned that I'm working with X-particles mostly, and perhaps something needs to be triggered for it aswell?

      I'm thinking there must be a way to get exactly what these two manual buttons presses do into one script, since it's all code underneath anyhow, right?

      Thanks again!

      posted in Cinema 4D SDK
      D
      Daguna
    • Timeline commands ran via Python script does not have same result

      Hi!

      This is probably not worthy to be called a developing question, but I think this might be the best place to ask, just please beware that I have zero knowledge in Python or scripting for C4D 🙂

      I'm trying to create a simple workflow script that rewinds the timeline to the start and then steps one frame forward, useful when doing particle sims for example. I then want to assign this script to be triggered by a keyboard shortcut so that these actions can be executed with a single button press instead of two.

      Following basic tutorials I got it somewhat working, but the strange thing is that it yields slightly different results in comparison to if I execute the commands manually. It seems the particle sim is not fully reset if ran via the script, but I have no clue to why that might be. I'm hoping there is an obvious simple thing I have missed, does anyone know?

      from typing import Optional
      import c4d
      
      doc: c4d.documents.BaseDocument  # The active document
      op: Optional[c4d.BaseObject]  # The active object, None if unselected
      
      def main() -> None:
          # Called when the plugin is selected by the user. Similar to CommandData.Execute.
          c4d.CallCommand(12501) # Go to Start
          c4d.EventAdd()
          c4d.CallCommand(12414) # Go to Next Frame
          c4d.EventAdd()
      """
      def state():
          # Defines the state of the command in a menu. Similar to CommandData.GetState.
          return c4d.CMD_ENABLED
      """
      
      if __name__ == '__main__':
          main()
      
      posted in Cinema 4D SDK 2024 python
      D
      Daguna