Change a rendering parameter in python xpresso node
-
Hi all
How to change a rendering parameter for an external engine.
For example for VRay:
I know the pluginID. I would like to be able to change the environment parameter from a python xpresso node. -
Hi @Passion3D, thanks for reaching out us.
With regard to your request, please consider that you can access the currently active document using the
doc
instance already existing in the Xpresso Python node. From this instance you can retrive the active RenderData using BaseDocument::GetActiveRenderData and from here retrieve the first BaseVideoPost using RenderData::GetFirstVideoPost().
Given the first BaseVideoPost, you can iterate over the videoposts until you find the right one and then change the parameter by accessing by reference its BaseContainer via BaseList2D::GetDataInstance().The code below attempts to modify the Filter Size of the ProRender videopost given the FilterDriver as
Float
parameter of the Xpresso Python Node.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 firstVP = activeRD.GetFirstVideoPost() # check and eventually make the change if firstVP.IsInstanceOf(1037639): firstVP.GetDataInstance()[c4d.VP_GPURENDERER_FILTERSIZE_OFFLINE] = FilterDriver
-
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 justgrep
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 thangrep
.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()
. -
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 classBaseList2D
, which is a quite common base class; from what I gather you need to useInsertShader()
with all classes that use a shader, whether it's material, render parameter, deformer or whatever.In
GeListNode
(one class up fromBaseList2D
) you will find the methodRemove()
, which can be applied to a shader, no need for a specific "RemoveShader". -
@Cairyn Thanks, all work fine for this module