item changing script needs to work on all characters in a scene
VicS
Posts: 1,273
my script is to show and hide items that G8F is wearing, it only works on the original g8 in the scene when the script was created-i need it to be able to show and hide items on any g8 in the scene, for example, there could be 4 g8F in the scene-the best scenario would be it can work from one script but if that is not doable to have a separate script for each g8F would also be great,
can someone give me a starting point how either one of these options can be achieved
thank you
Comments
You can use Scene.getPrimarySelection() to get a pointer to the primary selection, if theer is one. There are also other methods on Scene that will return arrays of all selected nodes, selected figures, etc. Remember, in using any of these, to make sure that there is a valid selection.
thanks Richard,
so I'm clear are you saying the script will only be able to work with more than one g8 at a time?
if that is true then must simply make a duplicate script for each g8 in the scene-and close and open each script for each character
No, I'm saying you can either get the primary Selection (one item) or, if you want to be able to process more than one figure at a time, you can use one of the options that gets an array of items.
It is possible if you use the getSelectedNodeList() method that can include multible selected figures or anything you have currently selected but you have to check that it is a figure. If the script should do something else depending on the selected figure you need to check which figure is selected. If you use one of the getNodeList() or findNode() methods you don't have to select anything like a figure or a node of a figure before running your script.
The methods to use are descriped here: