Scripting Parameter settings
Trying to learn daz scripting through building a random face generator for G9. Hopefully someone can explain what I'm missing. Why does the property value "Proportion Head Size" change but not "Asymmetry Ears 01 Left" or right? Are they not both properties? I've tried multible searches, several ways of coding out the properties. and the "Asymmetry" always comes back as a null and says not part of the object. What am I missing? Any help appreciated.
Code Below:
// Ensure a figure is selectedvar oFig = Scene.getPrimarySelection();// Random floating point number generator for property value function customFloat(min, max) { return Math.random() * (max - min) + min; } // Create an array for our properties var earProperties = ["Proportion Head Size", "Asymmetry Ears 01 Left", "Asymmetry Ears 01 Right"];if (oFig && oFig.inherits("DzSkeleton")) { var oObject = oFig.getObject(); if (oObject) { // Cycle through array and change the properties for (var i = 0; i < earProperties.length; i++) { var currentProperty = earProperties[i]; var oProp = oFig.findPropertyByLabel(currentProperty); // Set select property to random value var randomNumber = customFloat(0.0,1.0); if (oProp) { oProp.setValue(randomNumber); } // DEBUG: Print the random number and array item. print("Random Number: " + randomNumber); print("Node Name: " + currentProperty); } }}
Post edited by jnorfleet_478f5a1c6b on

Comments
Because two ears properties are DzMorph, i.e. their Owner is not Genesis 9 Node, that's why your code didn't work for them. (check the Owner in Parameter Settings, as shown in the attached screenshot ~)
So, with the script, you can handle them separately, as below:
// ============================================================
// DAZ Studio 6
// ============================================================
var fg = Scene.getPrimarySelection();
function rnd() {
return Math.random();
}
// Proportion Head Size
var p = fg.findPropertyByLabel("Proportion Head Size");
if (p) {
var v = rnd();
p.setValue(v);
}
// Ear Morphs
var obj = fg.getObject();
var n = obj.getNumModifiers();
for (var i = 0; i < n; i++) {
var m = obj.getModifier(i);
if (!m || !m.inherits("DzMorph"))
continue;
var name = m.getName();
if (name == "head_bs_AsymmetryEars01Left" ||
name == "head_bs_AsymmetryEars01Right") {
var v = rnd();
m.getValueControl().setValue(v);
}
}
(Edit: Do not use Script Snippet, it's not really readable nowadays... for some reason.)
I can't thank you enough for your response, it answered other questions I had outside the scope of my original question. And thank you for the code example and parameter screenshot, that caused a paradigm shift in my view of things.. Again, I can't thank you enough.
NP !