Rendering with specific camera ?



  • 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



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



  • 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()
    

Log in to reply