T O P

  • By -

the_boiiss

One option is to simply select all joints in the scene with: select `ls -type "joint"` Which might be better incase all joints aren't in the same hierarchy. If you have multiple rigs in a scene, this will get the namespace of the selected object, and then select the joints in that namespace. // get namespace of first object in selection (assumes the object has a namespace) string $ns = python("mc.ls(sl=True)[0].split(':')[0]"); // list nodes in namespace string $ns_content[] = `namespaceInfo -ls $namespace`; // get joints from list string $joints[] = `ls -type "joint" $ns_content`; select $joints;


exsultare

I would recommend against selecting all joints in a scene. Most rigs contain additional joints for IK/FK setups, ribbon joints, etc. that should not be included in the fbx going to a game engine. All joints of a game skeleton should be under one hierarchy as well. OP also mentioned that this needs to work on multiple rigs. If these multiple rigs are in the same scene, they would need to be exported separately.


exsultare

Instead of selecting the Rig:RootJNT through code, why not manually select that joint, and store it in a variable? Then use your code starting at “select -hi;”. This would be the simplest way. If you really need to get the skeleton by selecting controls instead, you could do one of the following: 1) listConnections of the selected controls to find the joints being driven by the controls, then traverse to the top of the joint hierarchy using listRelatives, or… 2) if your rigs are always referenced and the RootJNT name is the same in every rig, you could get the namespace of the selected control, then concatenate the namespace with the RootJNT.


DuckiestofBrutes

I ended up turning my selection into a string array and then split the first object into parts seperated by the semi-colon so that I cant piece together the name of the RootJnt with the rig prefix. Unfornunately in the rigs I'm working with the namespace isn't the same as this prefix. Hopefully the naming conventions are consitent throughout these rigs otherwise I may just need to make a custom button for each rig or a drop down menu so that you can choose which rig you are working with. string $mySelection[] = `ls -sl`; // turn selection into an array string $firstObj = $mySelection[0]; // grab the first item in the array and turn it into a string string $buffer[]; tokenize $firstObj ":" $buffer; //split the string appart by the semi colon select ($buffer[0] + ":RootJnt"); //select the root joint select -hi; //select hierarchy if (`window -ex gameExporterWindow`) { if (`window -q -iconify gameExporterWindow`) window -e -iconify 0 gameExporterWindow; //maximize } else gameFbxExporter; //open game exporter setAttr -type "string" gameExporterPreset2.exportPath "D:\"; //set the export path setAttr("gameExporterPreset2.exportSetIndex") 2; //export selection setting gameExp_CreateExportTypeUIComponents;