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

    How to run Python script at moment scene is opened?

    Cinema 4D SDK
    python r20 r21
    3
    4
    834
    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.
    • W
      wob
      last edited by

      I'm trying to write cinema 4d python script, that will auto-run render function when scene is opened. How to run Python script at moment scene is opened?

      Thanks

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by

        Hi,

        unfortunately the is no feature in Cinema that will let you execute a script when a document has been loaded.

        1. Technically you could abuse one of the scripting nodes to do what you want to do, but I would not recommend this, due them being bound to a threaded execution and other pitfalls.
        2. You could write yourself a plugin that does what you want. A MessageData plugin could be used for that for example.
        3. When you are not interested Cinema's GUI, you could also use c4dpy. Here I have recently shown, how you could use c4dpy to execute scripts on documents from the command line.

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • ManuelM
          Manuel
          last edited by Manuel

          hi,

          welcome to the forum and thanks for reaching us. 🙂

          The workflow you are trying to achieve is a bit strange. Executing a script to launch a render when you open a scene is not something you always want to be active.

          as @zipit said, if you want to launch render you can use c4dpy or our CommandLine

          You could also create a script that ask for a folder and than open, launch the render and close the scene.
          In our example you will find an example on how to launch a render

          Using a MessageData will not really help since the message sent when you open a document need to be catched by the Message function and the MessageData only rely on CoreMessage.

          Of course if you have any question feel free to ask. (we like to keep one thread per question)

          I forgot in c++ you have the SceneHookData but it's not available in python.

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 1
          • ManuelM
            Manuel
            last edited by

            hi,

            i'll set that thread to solved tomorrow without further feedback

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

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