Script for setting Morph and Parent
3dOutlaw
Posts: 2,471
My goal is to create a icon that a user can click and it will position the selected figure, set a morph value, and parent it to another.
I've got the positioning part done, and it works well, but I am stuck on how to set a morph value (like Young = 100%) and the parent to...
Can anyone point me in the right direction on that?
Comments
For example, this is the method I am using for setting position and scale:
Since I have the primary selection...looking for a way to set a morph value?
Use findProperty( name ) on the node to get the conmtroller, and then treat it as you do the XRotControl.
Thanks, so I got this to work for morphs in the "Actor" area of the figure, but when I use the same for a morph in the "Morphs" area, it does not modify it?
OK, I think I can figure it out using this as an exmaple. The second example here shows the morphs I need, so I should be able to use that to get/set the morphs
http://docs.daz3d.com/doku.php/artzone/wiki/user/rbtwhiz/technotes/daz_script/node_properties/start
One step at a time, in case it helps others:
Getting a list of group paths for a node
...hmmm, this may be beyond me... I can now get the path I want, but I think then I need to sort through the array of properties, and get the property and then I am not sure if I can even set it, ugh.
It would be nice to be able to specify this directly, given I know the group/path name, node name and property name, like node.group.path.property.setvalue(1)
Here is hoping that someone has done this before, and can throw me a bone? I am actually trying to make a freebie, so I will pay it forward!
Why are you wanting to go through the path? If you aren't getting the morphs from the figure (or bone) node try going (Bone>)Figure>Object and getting the modifier from that.
Well, I was following the link above, which if pasted and run (the second script shown) Rob was able to list out all of the morphs. In that example, he goes through the path, it looks like. I just assumed that was the only way to get the morph.
That being said, I used what you said, and found some of your old helps, linked below and got it, thanks!
http://www.daz3d.com/forums/discussion/13295/setting-parameter-value-by-name
Now I just need to figure out the second part, how to Parent that object to another, though I may just leave that as part of the instruction (i.e. run this script, that parent to figure) if it takes too long to figure out.
Thanks Richard, always very helpful!
Use node.addNodeChild( child ) - it's slightly unexpected as the UI always refers to setting the parent, but in scripting we are adding a child to the parent.
Don't forget that Rob's samples are not Public Domain, they do require attribution (that is to the samples page, so that people can find the original) if you adapt them in your scripts.
OK I'll try that.
No problem on the attribution, I acutally used your forum posts more than his notes. That will be what is in my end freebie. In any case, I will give credit to both he and you (and Casual) for assistance in the README to cover all bases.
You should start a sticky with API Examples when you or someone comes up with them! For example, you had a nice visibility example here:
http://www.daz3d.com/forums/discussion/21827/script-to-toggle-visibility-of-a-node-and-all-children-nodes
Found it via google. I am not sure these are all in the API samples, but a Forum sticky about it, with basic user examples would be cool (unless there is something similar I missed already).
Here is the end result for me, made general for others benefit:
I am not a programmer...lol
Heh, I can't recall what I've posted over the years - I know I have on occasion reinvented my own wheels.
I would put some error checking in there - make sure that there is a node before doing anything with it, make sure you have an object before trying to get its modifier and so on. If not the script will just exit with an error in the log file, while explicitly checking allows you to at least pop-up an explaantory alert before stopping.
hello,
thanks for this helpfull thread 3dOutlaw
Hello guys i want to print all morphs of Genesis 8 female , below is my code but it mot working
var genesis8Female = Scene.findNodeByLabel("Genesis 8.1 Female");
if (genesis8Female) {
adjustCrotchHeightToTargetValue(genesis8Female, );
} else {
print("Genesis 8.1 Female node not found.");
}
function adjustCrotchHeightToTargetValue(node) {
var mod1 = node.findModifier("Height");
print(mod1);
}
As I said in the otehr thread, is this your code or AI generated code? Whata re you trying to do - you can't just "print a modifier", you need some specific detail (e.g. its name or label, or both). Have you looked at the sample script that shows how to get modifiers for a figuer? Remember that morphs belong to the shape that belongs to the figure, not the figure itself.
Can you help with script to modify Height slider on Genesis 8 female body