Exemple #1
0
def selectInReferenceEditor():
    """
    SELECTE THE FIRST reference in the referenceEditor related to the current seclection
    """
    # get glbal name of the reference editor panel from mel
    gReferenceEditorPanel = mel.eval("$temp_1 = $gReferenceEditorPanel")
    #get all referenced files names
    all_ref_f = pm.listReferences()
    refNode  = getRefNodes(pm.selected())
    if refNode:
        index = all_ref_f.index(refNode[0])
    pm.sceneEditor(gReferenceEditorPanel,si = index,e=True)
Exemple #2
0
    def select_reference_in_reference_editor(cls):
        """selects the reference node in the reference editor related to the
        scene selection
        """
        selection = pm.selected()
        if not selection:
            return

        node = selection[0]
        ref_file = node.referenceFile()

        if ref_file is None:
            return

        ref_node = ref_file.refNode

        # gather reference editor data
        ref_editor_panel = pm.mel.globals['gReferenceEditorPanel']
        ref_editor_data = {}

        i = 0  # be safe
        while True and i < 1000:
            try:
                pm.sceneEditor(ref_editor_panel, e=1, selectItem=i)
            except RuntimeError:
                break

            sel_ref_node_name = \
            pm.sceneEditor(ref_editor_panel, q=1, selectReference=1)[0]

            ref_editor_data[i] = pm.PyNode(sel_ref_node_name)
            i += 1

        for i, ref_editor_ref_node in ref_editor_data.items():
            if ref_editor_ref_node == ref_node:
                pm.sceneEditor(ref_editor_panel, e=1, selectItem=i)
Exemple #3
0
def Ref2Node():
    refEd = mel.eval(
        'global string $gReferenceEditorPanel;string $a = $gReferenceEditorPanel'
    )
    sel_ref = pm.sceneEditor(refEd, q=True, sr=True)
    allRefs = pm.listReferences()
    ref_nodes = [
        eaRef.refNode for eaRef in allRefs if eaRef.refNode.name() in sel_ref
    ]
    sel_ref_dict = {}
    for ea_sl_rf in ref_nodes:
        temp_lst = [
            ea_nd for ea_nd in ea_sl_rf.nodes()
            if ea_nd.type() == 'transform' and
            (not ea_nd.getParent(1) or not ea_nd.getParent(1).isReferenced())
        ]
        top_parents = []
        for ea_tmp in temp_lst:
            top_p = get_top_ref(ea_tmp)
            if top_p not in top_parents: top_parents.append(top_p)
        sel_ref_dict[ea_sl_rf] = top_parents
    return sel_ref_dict