@classmethod
    def duplicate_selected_reference(cls):
        all_selected_refs = []
        for sel_node in pm.ls(sl=1):
            ref = sel_node.referenceFile()
            if ref not in all_selected_refs:
                all_selected_refs.append(ref)

        for ref in all_selected_refs:
            # get the highest parent ref
            if ref.parent():
                while ref.parent():
                    ref = ref.parent()

            namespace = ref.namespace
            dup_ref = pm.createReference(
                ref.path,
                gl=True,
                namespace=namespace,
                options='v=0'
            )

            top_parent = cls.get_no_parent_transform(ref)
            if top_parent:
                node = top_parent
                tra = pm.xform(node, q=1, ws=1, t=1)
                rot = pm.xform(node, q=1, ws=1, ro=1)
                sca = pm.xform(node, q=1, ws=1, s=1)

                new_top_parent_node = cls.get_no_parent_transform(dup_ref)
                pm.xform(new_top_parent_node, ws=1, t=tra)
                pm.xform(new_top_parent_node, ws=1, ro=rot)
                pm.xform(new_top_parent_node, ws=1, s=sca)

                # parent to the same group
                group = node.getParent()
                if group:
                    pm.parent(new_top_parent_node, group)

                # select the top node
                pm.select(new_top_parent_node)
Creates a button.
dataset/ETHPy150Open eoyilmaz/anima/anima/env/mayaEnv/toolbox.py/Reference.duplicate_selected_reference--crossover with--dataset/ETHPy150Open enthought/traitsui/traitsui/wx/ui_base.py/BaseDialog.add_button