Locking/Unlocking joints through script

Hey there,

 

quick question for those of you who are familiar with scripting in DS. I am looking to lock/unlock a selection of nodes (in my example it would be all the toe joints) and do this with a script instead of having to select the joints manually, then hit lock/unlock keys that I have mapped. This is really cumbersome and takes alot of time for a very simple thing.

Would be nice if someone could paste me a couple lines of code or maybe even some quick explanation with a list of variables that could be controlled through a similar script?

 

Anyhow, looking forward to any help I can get.

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,749
    edited March 2017

    Get the figure (use Scene.getSelectedSkeletonList() for example), then iterate over that and for each selected figure use node.findNodeChild( name , true) to get the toe bones (true is needed or it will check only the immediate children of the figure - name you can get by selecting the bone and using the Scene ID command). Once you have the bone(s), you can use the node.getXRotControl() etc. functions to get the transform properties and then property.lock( true ) to lock it (or proeprty.lock( false ) to unlock).

    Post edited by Richard Haseltine on
  • YudinEdYudinEd Posts: 90
    edited March 2017

    I think this look so (tested). True or false - lock or not lock. As Richard Haseltine wrote

    var bones = Scene.getSelectedNodeList();for ( var n = 0 ; n < bones.length ; n++ ) { if ( bones[ n ].getXRotControl() ) {  bones[ n ].getXRotControl().lock( true ); } if ( bones[ n ].getYRotControl() ) {  bones[ n ].getYRotControl().lock( false ); } if ( bones[ n ].getZRotControl() ) {  bones[ n ].getZRotControl().lock( false ); }}

     

    Post edited by YudinEd on
  • Richard HaseltineRichard Haseltine Posts: 100,749

    Yes, that will work if you just want to lock/unlock selected bones. I think the OP was wanting to avoid the need to select the specific target bones, however, which was why I suggested getting selected figures (where it doesn't matter what is selected) and then getting the bones by name.

  • hzrhzr Posts: 207

    Yup, already got it. Thanks for the replies :)

Sign In or Register to comment.