Beginner asking for help: How to select a character in the scene
Dorlan
Posts: 4
Hello,
I have just started to learn javascript to create some little tools in daz and I have already played with some variables and functions, but I really struggle to find by myself how to select a character using his name in the script and have the possibility to toggle between several characters.
My goal is to have the possibility to select and toggle between the characters with one hotKey.
I hope I'm clear enough even if I'm a new at scripting...
Thank you!
Comments
DzScene has methods to get nodes in general or of specific types, including skeletons (selected or otherwise). If you want to chnage the selection state you need
node.select( true/false );
to gt the current selection state
var state = node.isSelected();
Thank You very much Richard, I will explore in this direction, Thank you again!
Alwright, I finally have found a way to select only the skeleton and it works... Thanks Richard! this is my script :
__________________________________________________
var skel = Scene.getSkeleton(0);
if( skel )
{
if( skel.inherits( "DzBone" ) )
{
skel = skel.getSkeleton();
}
skel.select( true);
}
_______________________________________
Is it correct?
Next, i have to find a way to toggle the selection between two skeletons.
Well, brick by brick...
getSkeleton( # ) should always return null or a skeleton, but there's no harm in double checking. As for toggling, assuming you have skel1 and skel2
might work.
Great! I have tried many things without any succes for the toggle part, but now it looks very clear when you show those conditions "if and else if", yes i have created two "skel", but it seems that i have missed something because the toggle doesn't work for the moment, but what you mean about "getskeleton(#) should always return null or a skeleton? Maybe that is what i do wrong... thank you very much for your help!
This is my new version :