Property not found in some cases. Why?

HI Daz Team and fellow scripters.

I try to write a script to select a property and changed its value via script.
Unfortunately, while it works from some of them, some come back not found, even if I used the exact same method.

It looks like a problem that some properties are nested, I could be wrong about that.

Does anyone have an idea how to solve this problem?

Thanks for your help

Here is the script:
 

// Function to select a characterfunction selectCharacter(characterName) {    // Get the figure by label    var figure = Scene.findNodeByLabel(characterName);    if (figure == null) {        print("Could not find figure: " + characterName);        return;    }    // Select the figure    figure.select();    print("Figure " + characterName + " has been selected.");    return figure;}// Function to list all properties of a characterfunction listProperties(figure) {    var numProperties = figure.getNumProperties();    var result = [];    for (var i = 0; i < numProperties; i++) {        var property = figure.getProperty(i);        result.push(property.getLabel());    }    return result;}// Function to set a specific property of a character to a given valuefunction setProperty(figure, propertyName, value) {    var numProperties = figure.getNumProperties();    for (var i = 0; i < numProperties; i++) {        var property = figure.getProperty(i);        if (property.getLabel() === propertyName) {            property.setValue(value);            print("Set property " + propertyName + " to " + value);            return;        }    }    print("Property " + propertyName + " not found");}// Call the function with the name of your charactervar figure = selectCharacter("name of the character in the scene");  // replace with your character nameif (figure) {    var properties = listProperties(figure);    print("Properties: " + properties.join(", "));    setProperty(figure, "Label of the property in the parameters panel", 1.0);  // set the property to 100%} else {    print("Character not found");}

 

Comments

Sign In or Register to comment.