Changing the value of a morph on a g8 figure

This seems insanely simple, but the sample scripting and other questions posted on here do not seem to have much direction to give me.

I want to change the value of a handful properties so I can run a script and have the selected propertyies' value change to a value written in the script.

I know how to select the figure and read the skeleton and locate bones, but I'm not quite sure how to find a property and then change its value. Is there something similar to "findbonebylabel" but for morphs?

 

Thanks.

Comments

  • If it's actual morph those are on the figure, not the bone. You get the object from the figure node http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/node_dz#a_1a5b6bf06e4ee1b03b841f22efb27b3e3b , then the modifier can be found on the object (by name, rather than label) http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/object_dz#a_1a259d193e74e4003ab512d904e214509c . Once you have the modifier you get its value channel as I recall (DzModifier dosc are curently offline) on which you can then use setValue( val ) or one of its variants (setting at a time, for example).

  • This seems to work, as a proof of conceept rather than a proper script:

    // make sure a figure is selectedvar oFig = Scene.getPrimarySelection();var oObject = undefined;// make sure we got a figureif ( oFig && oFig.inherits( "DzSkeleton" ) ) {	// get the object	oObject = oFig.getObject();}// if we have a valid objectif ( oObject ) {	// get the Forearm Size morph	var oMorph = oObject.findModifier( "PBMForearmsSize" );		// get its value channel, if it was found	if ( oMorph ) {		var oValChan = oMorph.getValueChannel();				// if successful, set it to 1		if ( oValChan ) {			oValChan.setValue( 1 );		}	}}

     

  • Thanks, Richard. That and some other code I found through Google was able to help.

    Appreciate the help, sorry for the late reply.

  • LAPLAP Posts: 3
    edited February 2021

    Comment removed. I think my suggestion was wrong now...

    Post edited by LAP on
  • Richard Haseltine said:

    This seems to work, as a proof of conceept rather than a proper script:

    // make sure a figure is selectedvar oFig = Scene.getPrimarySelection();var oObject = undefined;// make sure we got a figureif ( oFig && oFig.inherits( "DzSkeleton" ) ) {	// get the object	oObject = oFig.getObject();}// if we have a valid objectif ( oObject ) {	// get the Forearm Size morph	var oMorph = oObject.findModifier( "PBMForearmsSize" );		// get its value channel, if it was found	if ( oMorph ) {		var oValChan = oMorph.getValueChannel();				// if successful, set it to 1		if ( oValChan ) {			oValChan.setValue( 1 );		}	}}

    I was able to get this to work, but not for morphs that are built-in to G8.1. For example, the morph in the attached image has the "Morph" category next to "Owner", and it will be found by the above script. But if you attempt to find morphs that are built-in to G8.1 (such as facs morphs) the script will fail to find them. I noticed that these morphs do not have "Morph" next to the Owner, they have "Node". Is there some other way to access these types of morphs via script?

    Capture.PNG
    699 x 150 - 9K
    Capture2.PNG
    605 x 98 - 4K
  • Of course, I find the solution shortly after posting here. The issue was that facs and eCTRL are not morphs, they are properties. I was able to modify their values using the following code:

    var node = Scene.getPrimarySelection();var sampleProp = "eCTRLMouthOpen";var found = 0;for(var i = 0; i < node.getNumProperties(); i++) {	if(!node.getProperty(i).getName().localeCompare(sampleProp)) {		print("Property was found");					node.getProperty(i).setValue(1);						found = 1;		break;		}}if(found == 0)	print("No property was found.");

    I'm not much of a programmer so apologies if this is wildly inefficient, just needed a method to automate the assigning of certain values with Daz characters for a separate project I'm working on.

Sign In or Register to comment.