Listing All Renderers



  • Hello,
    I'm trying to get a list of all available Renderers. The code I have below only works with Renderers that have been activated:

    import c4d
    from c4d import gui
    from collections import namedtuple
    
    RenderEngine = namedtuple('RenderEngine', 'id name')
    
    def getRenderEngines():
        rd = doc.GetFirstRenderData()
        renderEngines = [RenderEngine(0,"Standard")]
        
        while rd:
            bvp = rd.GetFirstVideoPost()
            bvpType = bvp.GetType()
            bvpName = bvp.GetName()
            renderEngines.append(RenderEngine(bvpType,bvpName))
            rd = rd.GetNext()
    
        for reng in renderEngines:
            print reng
    
    def main():
        getRenderEngines()
        c4d.EventAdd()
    
    if __name__=='__main__':
        main()
    

    Because I have changed my document's renderer to Hardware OpenGL, the above code prints the following, but leaves out the others in the screenshot...

    RenderEngine(id=0, name='Standard')
    RenderEngine(id=300001061, name='Hardware OpenGL')
    

    Renderers.png

    How can I get all of the renderers? Thank you!



  • Hi, I confirm, a render data only store the current setting for the current render.

    However, there is some special condition, and especially the standard render is not registered as a render and really hardcoded.
    So here how to retrieve the exact same content than what is available in the render setting windows.

    import os
    import c4d
    
    def GetRenderData():
        # Hardcoded ID
        IDS_RM_ENGINE = 17000 + 596
        IDS_RM_ENGINE_OPENGL = 17000 + 599
        
        # Load render resource
        c4dFolder = os.path.dirname(c4d.storage.GeGetStartupApplication())
        resDir = os.path.join(os.path.dirname(c4dFolder), "resource", "modules", "c4dplugins")
        res = c4d.plugins.GeResource()
        res.Init(dir)
        res.InitAsGlobal()
        
        # Standard is special, and maunually added
        renderEngine = []
        renderEngine.append({"id": c4d.RDATA_RENDERENGINE_STANDARD, "name": res.LoadString(IDS_RM_ENGINE)})
        
        # Physical is always the second entry
        bs = c4d.plugins.FindPlugin(c4d.VPxmbsampler, c4d.PLUGINTYPE_VIDEOPOST)
        if bs is not None:
            renderEngine.append({"id": c4d.VPxmbsampler, "name": bs.GetName()})
            
        # PreviewHardware always the third, but here only if OpenG: is active
        if bool(c4d.GeGetCinemaInfo(c4d.CINEMAINFO_OPENGL)):
            renderEngine.append({"id": c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE, "name": res.LoadString(IDS_RM_ENGINE_OPENGL)})
        
        # List all videopost
        pluginList = c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_VIDEOPOST, True)
        for plugin in pluginList:
        
            # Already added stuff, so dont had then 2 times
            if plugin.GetID() in (c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE, c4d.VPxmbsampler):
                continue
    
            # If the plugin is not a render, continue
            if not plugin.GetInfo() & c4d.PLUGINFLAG_VIDEOPOST_ISRENDERER:
                continue
        
            renderEngine.append({"id": plugin.GetID(), "name": plugin.GetName()})
    
        return renderEngine
    
    
    for renderEngine in GetRenderData():
        print renderEngine
    

    Cheers,
    Maxime.



  • Hi,

    aside from the fact that your code does not return all render engines, but the name of allBaseVideoPost nodes, which would also include anything else that can be a post effect, I think the general approach is flawed. Trying to arbitrarily identify any installed render engine is unnecessarily complicated, as you can easily exhaustively enumerate them. Either gather the plugin ids of all render engines and check for these or simply compile a list renderer names and browse the plugin nodes looking for these names - trading the risks of a name based identification for the hassle of dealing with integer based identification.

    Cheers
    zipit



  • Well, what is a renderer?

    If a renderer is a VideoPost-plugin with the flag PLUGINFLAG_VIDEOPOST_ISRENDERER, then you can simply check all registered video post plugins:

    pluginList = c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_VIDEOPOST, True)
    
    for plugin in pluginList:
        
        info =  plugin.GetInfo()
        if info & c4d.PLUGINFLAG_VIDEOPOST_ISRENDERER:
            print plugin
            print("is renderer")
    


  • Hi, I confirm, a render data only store the current setting for the current render.

    However, there is some special condition, and especially the standard render is not registered as a render and really hardcoded.
    So here how to retrieve the exact same content than what is available in the render setting windows.

    import os
    import c4d
    
    def GetRenderData():
        # Hardcoded ID
        IDS_RM_ENGINE = 17000 + 596
        IDS_RM_ENGINE_OPENGL = 17000 + 599
        
        # Load render resource
        c4dFolder = os.path.dirname(c4d.storage.GeGetStartupApplication())
        resDir = os.path.join(os.path.dirname(c4dFolder), "resource", "modules", "c4dplugins")
        res = c4d.plugins.GeResource()
        res.Init(dir)
        res.InitAsGlobal()
        
        # Standard is special, and maunually added
        renderEngine = []
        renderEngine.append({"id": c4d.RDATA_RENDERENGINE_STANDARD, "name": res.LoadString(IDS_RM_ENGINE)})
        
        # Physical is always the second entry
        bs = c4d.plugins.FindPlugin(c4d.VPxmbsampler, c4d.PLUGINTYPE_VIDEOPOST)
        if bs is not None:
            renderEngine.append({"id": c4d.VPxmbsampler, "name": bs.GetName()})
            
        # PreviewHardware always the third, but here only if OpenG: is active
        if bool(c4d.GeGetCinemaInfo(c4d.CINEMAINFO_OPENGL)):
            renderEngine.append({"id": c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE, "name": res.LoadString(IDS_RM_ENGINE_OPENGL)})
        
        # List all videopost
        pluginList = c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_VIDEOPOST, True)
        for plugin in pluginList:
        
            # Already added stuff, so dont had then 2 times
            if plugin.GetID() in (c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE, c4d.VPxmbsampler):
                continue
    
            # If the plugin is not a render, continue
            if not plugin.GetInfo() & c4d.PLUGINFLAG_VIDEOPOST_ISRENDERER:
                continue
        
            renderEngine.append({"id": plugin.GetID(), "name": plugin.GetName()})
    
        return renderEngine
    
    
    for renderEngine in GetRenderData():
        print renderEngine
    

    Cheers,
    Maxime.



  • @m_adam You are a genius - I am in awe!

    Thank you everyone for the help!


Log in to reply