How to script creation of an empty morph with specified name and path?
Falco
Posts: 241
I have this code copied from this thread https://www.daz3d.com/forums/discussion/comment/2660216/.
It works fine to create an empty morph with the settings I want, but it creates it as label Value in the path Morph, which im guessing is the default since this doesn't seem to be defined anywhere in the script.
What would I need to add to have it create it with label fix in the path ZBrush?
var newMorphDeltas = new DzMorphDeltas();var oNode = Scene.getPrimarySelection();if( oNode ){ var oObject = oNode.getObject(); if( oObject ){ var oShape = oObject.getCurrentShape(); if( oShape ){ var oGeometry = oShape.getGeometry(); if( oGeometry ){ var nVerts = oGeometry.getNumVertices(); for( var i = 0; i < nVerts; i += 1 ){ newMorphDeltas.addDelta(i, 0, 0, 0, true); } } } } var newMorph = new DzMorph( newMorphDeltas ); oObject.addModifier (newMorph, -1); var curModifier = oObject.getModifier(oObject.getNumModifiers()-1); curModifier.setName( "fix" ); var curProperty = newMorph.getValueChannel(); curProperty.setValue( 1 ); curProperty.setMin( 0 ); curProperty.setMax( 1.0 ); curProperty.setIsClamped ( true ); curProperty.setCanAutoFollow( false );}
Post edited by Richard Haseltine on
Comments
Moved to the scripting forum.
fix is a bit generic as a name, but DzProperty http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/property_dz gives you waht you want, via DzProperty::setLabel() and DzProperty::setPath()
Thanks, got it working.
The workflow for this script is basically creating a generic fix morph that is already on, so I can quickly add it to all my clothing items in a scene so when I goz them I can just overwrite them and they'll automatically be active instead of having to go into the item and turn it on every time.
After some extended use of this script, one issue that I'm running into is that the name being blank is causing some issues when goz overwrites it. Is there any way to set the name as well? I can't find any property that corresponds to that field that can be set through script.
Do these not do what you want?:
Yep, got that working to set the name. Thanks!
BTW, with the initial code, the morph labeled as "value" with an empty internal name, happens only with figures for me, props instead get a proper "fix" name.
I didn't try it with props, that could well be the case. In case it's useful, this is the final code I'm using that fixes that issue.
Btw, I don't use this on an actual character because having the same morph name on a figure as a clothing item will cause the clothing item morph to become a hidden autofollow morph or whatever and I generally don't want that. I basically apply it to all clothing items and use it to fix pokethrough in zbrush, and do any character adjustments with manually created morphs that have different names.