Change a rendering parameter in python xpresso node



  • Hi,

    I am a bit confused. If you have the plugin id, I do not quite understand what exactly the problem is. You will have to get the plugin instance with c4d.plugins.FindPlugin(PLUGIN_ID) and then change the parameter on the returned node.

    For the case that you misspoke and actually meant that you know the symbol of the parameter and not the id of the plugin, here you can learn how to find out the plugin id for any node in Cinema 4D. The link is an example for an entry in the preferences dialog, but it will work exactly the same for a VideoPost plugin. You can of course also just grep the plugin folder, but since Vray has probably more than one plugin id (i.e. consists of multiple plugins), inspecting the node type in question in the console is probably a bit faster than grep.

    Cheers,
    zipit



  • @zipit said in Change a rendering parameter in python xpresso node:

    Hi,
    I am a bit confused. If you have the plugin id, I do not quite understand what exactly the problem is.

    You're right @zipit, nothing to get confused about it was just me taking a different mind path. Your proposed approach is indeed correct and also more effective. Thanks for pointing it out!



  • Thanks to both of you ;) I'll test all this tomorrow and let you know the result.



  • What's wrong in my code?

    import c4d
    
    def main():
        # check doc
        if doc is None:
            return
    
        # get the active RenderData
        activeRD = doc.GetActiveRenderData()
        if activeRD is None:
            return
    
        # get the first BaseVideoPost (Active Render)
        firstVP = activeRD.GetFirstVideoPost()
        if firstVP is None:
            return
        shader = firstVP[c4d.VP_VRAYBRIDGE_ENVIRONMENT_BACKGROUNDTEX]
        if shader == None:
            shader = c4d.BaseShader(c4d.Xbitmap)
            firstVP.GetDataInstance()[c4d.VP_VRAYBRIDGE_ENVIRONMENT_BACKGROUNDTEX] = shader
        shader[c4d.BITMAPSHADER_FILENAME] = "approaching_storm_4k.hdr"
        c4d.EventAdd()
    
    if __name__=='__main__':
        main()
    
    


  • This post is deleted!


  • Shader creation requires inserting the shader using InsertShader().

    E.g. Python Generator - Adding Shaders to Deformer Objects.



  • This post is deleted!


  • @PluginStudent
    Your link is about the creation of a material (and that I already know how to do), not a render parameter.

    But I have tound the solution.

        shader = firstVP[c4d.VP_VRAYBRIDGE_ENVIRONMENT_BACKGROUNDTEX]
        if shader == None:
            shader = c4d.BaseList2D(c4d.Xbitmap)
            firstVP.InsertShader(shader)
            firstVP.GetDataInstance()[c4d.VP_VRAYBRIDGE_ENVIRONMENT_BACKGROUNDTEX] = shader
        shader[c4d.BITMAPSHADER_FILENAME] = "approaching_storm_4k.hdr"
    
    

    Other question, how to remove it? I don't have found "DeleteShader" or "RemoveShader"🤔



  • @Passion3D The link is about a deformer, not a material. InsertShader() is a function of the class BaseList2D, which is a quite common base class; from what I gather you need to use InsertShader() with all classes that use a shader, whether it's material, render parameter, deformer or whatever.

    In GeListNode (one class up from BaseList2D) you will find the method Remove(), which can be applied to a shader, no need for a specific "RemoveShader".



  • @Cairyn Thanks, all work fine for this module 👍


Log in to reply