Creating a simple DzERCLink between two new parameters

3dcheapskate3dcheapskate Posts: 2,719

My script creates two brand new parameters.

I want to connect them using an ERCLink, with a predefined scaling factor (old-school 'deltaAddDelta' with a factor of 0.5).

But how ? (Read the bottom part of the code to see my problem)

Here's the basics:

		// Set up the master property	var oProperty1 = new DzIntProperty();	oProperty1.name = "Texture Column (0 or 1)"	oProperty1.setLabel( "Texture Column (0 or 1)" );	oProperty1.setPath( "Book Selection" );	oProperty1.setIsUserProperty( true );	oProperty1.setNew( true );	oProperty1.setMin(0);	oProperty1.setMax(1);	oProperty1.setIsClamped(true);	oProperty1.setSensitivity(1);	oProperty1.setValue(0);	oNode.addProperty( oProperty1 );		//Set up the slave property	var oProperty2 = new DzFloatProperty();	oProperty2.name = "Horizontal Offset"	oProperty2.setLabel( "Horizontal Offset" );	oProperty2.setPath( "Book Selection/Material Tiling Proxies" );	oProperty2.setIsUserProperty( true );	oProperty2.setNew( true );	oProperty2.setDisplayAsPercent( false );	var oPropertyAlreadyThere = findElementProperty( oNode, oProperty2.name );	oNode.addProperty( oProperty2 );		// Create a new DzERCLink (which inherits from DzNumericController and DzController)	// It appears that both the constructor and 'setProperty()' connect the master...	oERCLink = new DzERCLink(oProperty) // I assume that this is the master ? It doesn't appear to be the slave.	oERCLink.setProperty(oProperty1) // "Sets the property that drives this link. " i.e. the master		// So I assume that to set upthe slave I now have to add oERCLink as a 'controller' to oProperty2	// DzProperty includes lots of '~~~~Controllers()' methods but I can't see any for ADDING a controller		// ??? BUT HOW ???	

This is related to my Creating dependencies between settings on the Surfaces tab and Parameters tab thread

Post edited by 3dcheapskate on

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,879

    This is snipped from a very old script of mine:

    	if ( masterProperty && slaveProperty ) {	    var ERCLink = new DzERCLink( type , multiplier , addend );	    if ( ERCLink ) {		ERCLink.setProperty( masterProperty );		slaveProperty.insertController( ERCLink );	    }	}

    which looks right by the current refs.

  • 3dcheapskate3dcheapskate Posts: 2,719
    edited July 2019

    yes Thanks Richard, DzNumericProperty::insertController() does the trick - I can't see how I overlooked it !

    This works...

    	oERCLink = new DzERCLink(); //Set up the controller	oERCLink.setProperty(oProperty1); // Set the master	oProperty.insertController(oERCLink); // Set the slave

     

    ...but I want to set the multiplier to 0.5.

    So I tried a different constructor (sidenote: yours isn't listed in the documentation)

    	oERCLink = new DzERCLink( ERCDeltaAdd, oProperty1, 0.5 ); //Set up the controller	oProperty.insertController(oERCLink); // Set the slave

    My script errorss and the log file gives me...

    WARNING: ReferenceError: Can't find variable: ERCDeltaAdd

     

    I just cannot work out how to use the ERCType enumeration ! (Yes,I'm very rusty)
    Obviously not just ERCDeltaAdd. Nor does it appear to be ERCType.ERCDeltaAdd (that appears to be the Java jive)...

     

    I've rummaged around in the DAZ Script basics to no avail. I've Googled 'qtscript enum' and  'ecmascript enum' and that just confused me even more.Anyway, here' are the relevant bits of documentation:

    stuff.jpg
    529 x 287 - 29K
    Post edited by 3dcheapskate on
  • Richard HaseltineRichard Haseltine Posts: 100,879

    Try DzERCLink.ERCDeltaAdd - the enumerations belong to the object, they are not globals.

  • 3dcheapskate3dcheapskate Posts: 2,719

    yesyes  Thanks again Richard !

Sign In or Register to comment.