item changing script needs to work on all characters in a scene

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

  • 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.

  • Syrus_DanteSyrus_Dante Posts: 983
    edited July 20

    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:

    [Quote] http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/scene_dz

    No Selection needed:

    DzNode : findNode ( String name )

    DzNode : findNodeByLabel ( String label )

    Number : getNumNodes ()

    Return Value: The number of nodes in the scene.

    DzNode : getNode ( Number index )

    Parameter(s): index - The index of the node to return.

    Return Value: The node at the given index (if valid), otherwise NULL.

    Array : getNodeList ()

    Return Value: A list of all nodes in the scene.


    If you want to ask for what is selected:

    DzNode : getPrimarySelection ()

    Return Value: The primary selected node in the scene, or NULL if there is no currently selected node. The primary selected node is the last node that was selected, or can be set via function calls.

    Number : getNumSelectedNodes ()

    Return Value: The number of currently selected nodes.

    DzNode : getSelectedNode ( Number index )

    Parameter(s): index - The index of the selected node to return.

    Return Value: The node at index in the list of selected nodes (if valid), otherwise NULL.

    Array : getSelectedNodeList ()

    Return Value: A list containing all selected nodes in the scene.

    Post edited by Syrus_Dante on
Sign In or Register to comment.