Help fetching Iray render property and adding step value

valzheimervalzheimer Posts: 519

First off, I'm a complete beginner at this, for as long as I've been around this forum best I can do is follow and combine existing examples, so beginner-level explanation would be appreciated.

Let's say I want to fetch the DzIrayRenderer property like Environment Intensity, but I want to add step value via script, for an example increase value by 0.5 to existing one every time script is innitiated. From my understanding I would use Render Settings - Find Property to locate Environment Intensity property but anything I do afterwards to set value doesn't function and I would appreciate some guildelines.

Beginning so far is consistent:

/==============================================================================////==============================================================================function getEnvironmentIntensity(){	var renderMgr = App.getRenderMgr();	var renderer = renderMgr.getRenderer( "DzIrayRenderer" );	if( !renderer )	{		return( 0 );	}	var renderElements = renderMgr.getRenderElementObjects();	var element = renderElements[1]; // NVIDIA Iray	var propGroups = element.getPropertyGroups();	var prop = propGroups.findProperty( "Environment Intensity" );

 

but here on I don't know how to manipulate further to get to getValue or setValue within the property that would match with the first part let alone step values like increasing by a number (I tried similar examples per nodes and objects but they must've led me rather wrong cause I can't make them work), so I'll just spare you all the fails I had and appreciate it if anyone would be willing to help :) Thanks.

Post edited by valzheimer on

Comments

  • By my reading, the scripting documenation says that that getRenderer() method of a DzRenderMgr object takes a Number argument, not a string.  You could find the correct number value for Iray by using the getNumberRenderers() method as the index of a loop, calling getRenderer() for each index and then using the getName() method on the DzRenderer object.

    The documentation says nothing about the getRenderElementObjects() method, so without writing test code to investigate it's hard to say whether your usage will work as you expect it to.

    In the past I have used the getPropertyHolder() method of the DzIrayRenderer object to get a DzElement object that holds the properties of the renderer.  Then the getPropertyList() method in the DzElement will get you an array of all the properties, or use findPropertyByLabel() to get a given property by name.  I have been able to set Min and Max Samples, and Max Time values by this method but do not know if Environment Intensity is available via this approach.

  • andya_b341b7c5f5andya_b341b7c5f5 Posts: 694
    edited December 2019

    Had another thought, and I think I have found it by way of the getPropertyGroups() method of the DzElement object.

    var oRenderMgr = App.getRenderMgr();App.log(String("Number of renderers: %1").arg(oRenderMgr.getNumRenderers()));	// List available renderersfor (var i = 0; i < oRenderMgr.getNumRenderers(); i++) {	var rndr = oRenderMgr.getRenderer(i);	App.log(String("Renderer %1: %2, %3").arg(i).arg(rndr.getName()).arg(rndr.objectName));};var renderer = oRenderMgr.getRenderer(0); //0 = Iray based on above outputprint(renderer.getName()); // 'NVIDIA Iray'var oRndrProps = renderer.getPropertyHolder();var oRndrPropList = oRndrProps.getPropertyList();print(String("Renderer has %1 properties").arg(oRndrPropList.length));for ( p=0; p < oRndrPropList.length; p++) {		print(String("Prop %1 label: <%2>").arg(p).arg(oRndrPropList[p].getLabel()));};// Get property treevar oPropGrpTree = oRndrProps.getPropertyGroups();// Get properties in this treevar allPropsInTree = oPropGrpTree.getAllProperties();print(String("Number of properties in tree = %1").arg(allPropsInTree.length));var oProp;var oSettings = new DzSettings();var oPropSettings = new DzPropertySettings(oSettings);// Loop through the properties in the treefor ( p = 0; p < allPropsInTree.length; p++) {	//print(String("Property name = %1").arg(allPropsInTree[p].getLabel()));	if (allPropsInTree[p].getLabel() == 'Environment Intensity') {		oProp = allPropsInTree[p];        print(oProp.getPath());        oProp.getAttributes(oPropSettings);        print(oPropSettings.toString());        // Get the value of Environment Intensity        print(oProp.getDoubleValue());        // Increase it by one        oProp.setDoubleValue(oProp.getDoubleValue() + 1);        print(oProp.getDoubleValue());	}};

     

    Post edited by andya_b341b7c5f5 on
  • Had another thought, and I think I have found it by way of the getPropertyGroups() method of the DzElement object.

    Wow thank you so much! This works perfect for what I need, and it's probably the only way I didn't try to call it in last night, it drove me completely crazy. 

Sign In or Register to comment.