Undocumented propertysettings_dz - is this the same as the old DzSettings? What's a key string?

(I've copied this post from here as a new thread, since it's not really related to the Iray renderer except by the context in which I was asking the question)

Using Rob's Render Settings - Find Property sample code I've got the properties I want. Now I look under DzProperty and reckon I need to do getAttributes / setAttributes, but the essential propertysettings_dz is as yet undocumented. I guess it's similar to the old DS3 DzSettings? So with a bit of educated guesswork I set up oProperty using Rob's sample code with "Environment Intensity" as the string and do this...

                var oPsettings = new DzPropertySettings;
                oProperty.getAttributes( oPsettings )
                print('>>> oP "Environment Intensity" = ',oPsettings.getFloatValue())

...(I know getFloatValue requires parameters - I'm getting to that) and I get this...

DEBUG: Found: Environment Map
WARNING: Script Error: Line 1839
WARNING: SyntaxError: too few arguments in call to getFloatValue(); candidates are
    getFloatValue(QString)
    getFloatValue(QString,float)

In the old DS3 DAZ Script 2 documentation it gives this

Number DzSettings::getFloatValue ( String key, Number def = 0.0 )
Parameters:
        key     The key string.

QUESTION 1: What is "the key string" ?

QUESTION 2: Am I heading in the right direction ?

Comments

  • I'm guessing that 'key string' is probably related to 'key/value' pairs, with the key string being the name of a specific parameter in the settings. If that's correct then how do I find out what the key strings are for a particular 'settings'?

  • Richard HaseltineRichard Haseltine Posts: 100,747
    edited November 2015

    Try

    var oPsettings = new DzPropertySettings;                prop.getAttributes( oPsettings );                for ( var n = 0 ; n < oPsettings.getNumValues() ; n++ ) {                	print ( oPsettings.getKey( n ) );                }

     

    to get the list of keys. I think the optional value in the two parameter version is so that you can set a default return if the key is undefined or missing. I used Rob's trick of going through the members of an object with

    for ( var n in oPsettings ) {     print( n );}

     

    to get the list of objects to try.

    Post edited by Richard Haseltine on
  • Thanks Richard. I'm probably doing something stupid as usual because with this (my 'getIrayProperty' is basically Rob's 'findElementProperty' with the 'If the application version is 4.7.1.44' bits removed, and the rest is basically Rob's - so I guess the changes I've made are what's messing it up! :D )

    function getIrayProperty(sIrayPropertyName)
    {
        var oElement, oProperty;
        for( var i = 0; i < g_aRenderElements.length; i += 1 ){
            oElement = g_aRenderElements[i];
            if( !g_sElementName.isEmpty() && oElement.name != g_sElementName ){
                if( !g_sElementName.isEmpty() )
                continue;
            }
            oProperty = findElementProperty( oElement, sIrayPropertyName, false, true );
            if( oProperty ){
                break;
            }
        }
        if( oProperty ){
                print( "Found:", oProperty.getLabel() )
                return(oProperty);
        }
        return null;
    }

    var oRenderMgr = App.getRenderMgr();
    var oRenderer = oRenderMgr.findRenderer( g_sRendererClassname );
    if( oRenderer ){
        oRenderMgr.setActiveRenderer( oRenderer );
        g_aRenderElements = oRenderMgr.getRenderElementObjects();
        oP = getIrayProperty("Environment Map")
        var oPsettings = new DzPropertySettings;
        oP.getAttributes( oPsettings )
        print("OPSETTINGS")
        for ( var n = 0 ; n < oPsettings.getNumValues() ; n++ )
            print ( oPsettings.getKey( n ) );

    gives me this:

    DEBUG: Found: Environment Map
    DEBUG: OPSETTINGS
    DEBUG: Label
    DEBUG: Hidden
    DEBUG: Path
    DEBUG: UserProperty
    DEBUG: CanAnimate
    DEBUG: Locked
    DEBUG: Manipulator
    DEBUG: Favorite
    DEBUG: GlobalFavorite
    DEBUG: Selected
    DEBUG: AutoFollow
    DEBUG: XYZInterest
    DEBUG: Clamped
    DEBUG: Mapable
    DEBUG: NeedMap
    DEBUG: DefaultImageGamma
    DEBUG: TextureModifierFlags
    DEBUG: Min
    DEBUG: Max
    DEBUG: Sensitivity
    DEBUG: AsPercent
    Importing File...

    which isn't anything like what I'm expecting.

    I'd expect an image filename and a strength slider value as the attributes of the "Environment Map". I guess I'm confusing my elements, objects, properties, etc ?

  • Those are the Parameter settings, the same ones (mostly, at least) as you see in the dialogue you can open from the slider's gear icon.

    What are you wanting to do - get the actual settings for the environment map? This seems a somewhat roundabout way to approach that though my brain seems to be making itss excuses and leaving so I may be missing the point.

  • djigneodjigneo Posts: 283

    Yeah, if you're looking to adjust the properties of the Environment map property, I think you're going down the wrong path with the Keys and Values business. It should be much easier than that, especially considering you've already found the property! =)

    oP = getIrayProperty("Environment Map");if (oP.inherits(DzFloatProperty.className())) {    oP.getValue();// or    oP.setValue(0.50);}

    Pretty sure you can expect the returned property to be a subclass of DzProperty, most likely a DzFloatProperty. Do a print(oP.className()) to be sure. Anyway, figure out what class it is, get / set the values on it via getValue(), getMapValue(), etc.

  • djigneo said:

    Yeah, if you're looking to adjust the properties of the Environment map property, I think you're going down the wrong path with the Keys and Values business. It should be much easier than that, especially considering you've already found the property! =)

    oP = getIrayProperty("Environment Map");if (oP.inherits(DzFloatProperty.className())) {    oP.getValue();// or    oP.setValue(0.50);}

    Pretty sure you can expect the returned property to be a subclass of DzProperty, most likely a DzFloatProperty. Do a print(oP.className()) to be sure. Anyway, figure out what class it is, get / set the values on it via getValue(), getMapValue(), etc.

    Thanks, I had a feeling it was a level issue but for soem reason wasn't seeing how.

  • djigneodjigneo Posts: 283
    edited November 2015

    To be clear, the "keys" list above is the Property settings as Richard said. (Screenshot attached.)

    parameter settings.png
    317 x 420 - 19K
    Post edited by djigneo on
  • 3dcheapskate3dcheapskate Posts: 2,719
    edited November 2015

    Richard/djigneo: Ah, yes! That's it - digging into the 'attributes' is going one step deeper than I want. I'm a little puzzled that getMapValue() is in DzNumericProperty , but other than that I think it more or less makes sense now. With the setttings for the Environment Map property, this...

    var oPsettings = new DzPropertySettings;
    print("oP.getValue()="+oP.getValue());
    print("oP.getMapValue().getFilename()="+oP.getMapValue().getFilename());

    ...gives me this...

    DEBUG: oP.getValue()=2
    DEBUG: oP.getMapValue().getFilename()=E:/DAZ/Studio4(64)/shaders/iray/resources/DTHDR-RuinsB-500.hdr

    I also want to get at the 'Draw Dome' ( DzBoolProperty ?), 'Dome Mode' ( DzEnumProperty ?) and various other things in the attached screenshot. I think I'm on the right path now!

     

    P.S. - djigneo - love your avatar!  laugh

     

    iray.jpg
    524 x 555 - 83K
    Post edited by 3dcheapskate on
  • mCasualmCasual Posts: 4,607
    edited July 2019

    i know it's an old thread but to increase the internet's codebase for this issue ...

     

    //==============================================================================////==============================================================================function getEnvironmentMap(){	var renderMgr = App.getRenderMgr();	var renderer = renderMgr.getRenderer( "DzIrayRenderer" );	if( !renderer )	{		return( 0 );	}	var renderElements = renderMgr.getRenderElementObjects();	var element = renderElements[1]; // the iRay one	var propGroups = element.getPropertyGroups();	var prop = propGroups.findProperty( "Environment Map" );	if( !prop )	{		return( 0 );	}	var map = prop.getMapValue();	if( !map )	{		return( 0 );	}	return( map.getFilename() );}

     

    erme.jpg
    960 x 867 - 85K
    Post edited by mCasual on
Sign In or Register to comment.