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

    Rendering with specific camera ?

    General Talk
    python
    4
    5
    1.0k
    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.
    • N
      nicholas_yue
      last edited by

      I am writing some scene assembly tool using C4D and c4dpy.

      I am bringing in Alembic cameras and other geometry assets.

      On the commandline.exe, there is no option to specify which camera I can render with so I am wondering if there is some python call I need to make to the C4D document before saving so that when I render the file, it knows which camera to use ?

      Cheers

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by

        You could use a Stage object and link the desired camera?
        Stage[c4d.STAGEOBJECT_CLINK] = ...

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

          Hi,

          I might be misunderstanding something here, but you can simply attach a camera to the render BaseDraw (which by default is the Perspective view port). See my example at the end of the post. You could also try to trigger the little active camera toggle option of the camera node, but if I remember correctly, this is not represented by BIT_ACTIVE like for a generator object, but in some weird special way. I know that it has been discussed on the old forum.

          Cheers,
          zipit

          """Simple example for creating a new render camera.
          
          Run this in the script manager, it will create a new camera and set it as
          the render camera.
          """
          
          import c4d
          
          def main():
              """Entry point.
              """
              # Get the render BaseDraw
              bd = doc.GetRenderBaseDraw()
              if not isinstance(bd, c4d.BaseDraw):
                  raise IOError("Could not access render BaseDraw.")
          
              # Create a new camera object,
              camera = c4d.BaseList2D(c4d.Ocamera)
              if camera is None:
                  raise MemoryError("Could not instantiate camera object.")
              
              # Inject the camera into the document and set it as the new render
              # camera.
              doc.InsertObject(camera)
              bd.SetSceneCamera(camera)
              c4d.EventAdd()
          
          if __name__ == "__main__":
              main()
          

          MAXON SDK Specialist
          developers.maxon.net

          1 Reply Last reply Reply Quote 2
          • r_giganteR
            r_gigante
            last edited by

            The proper way, as pointed out by @zipit, to set the scene active camera is to use BaseDraw::SetSceneCamera(). Any other special weird way are needed or recommended.

            Best, R

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

              Hi,

              without further feedback, we will consider this thread as solved by Wednesday and flag it accordingly.

              Cheers,
              Ferdinand

              MAXON SDK Specialist
              developers.maxon.net

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