src/jmLightToolkit.py
def createSet(self):
        """ Create Set then put transform node selected. """
        # GET SELECTED
        include_type = ["mesh", "aiStandIn", "pgYetiMaya"]
        selected = pm.selected()
        pre_setname = selected[-1].name().split("_")[0]

        shapes = []
        for node in selected:
            shapes.extend([node for node in node.getChildren(ad=True, s=True) if pm.nodeType(node.name()) in include_type])

        transforms = [shape.getParent() for shape in shapes]

        if not transforms:
            _logger.warning("Invalid selection")
            return None

        # Prompt Dialog
        result = pm.promptDialog(
            title='Create Set',
            message='Name:',
            button=['OK', 'Cancel'],
            defaultButton='OK',
            cancelButton='Cancel',
            dismissString='Cancel',
            text=pre_setname,
        )

        if result == 'OK':
            input_ = pm.promptDialog(query=True, text=True)
        else:
            _logger.warning("Set need a name")
            return None

        # ROOT SET
        if pm.objExists("root_SETS"):
            root_set = pm.PyNode("root_SETS")
        else:
            pm.select(cl=True)
            root_set = pm.sets(n="root_SETS")

        # CREATE SET
        if re.search(r'[A-Za-z0-9_]+(_SETS)', input_) is None:
            input_ = "%s_SET" % input_

        pm.select(cl=True)
        set_ = pm.sets(n=input_)
        set_.addMembers(transforms)
        pm.sets(root_set, fe=set_)

        pm.select(selected)
        _logger.info("%s" % set_)
        return set_
 Create Set then put transform node selected. 
Create Set then put transform node selected.
Create Set then put transform node selected .
def createSet(self):
        include_type = ["mesh", "aiStandIn", "pgYetiMaya"]
        selected = pm.selected()
        pre_setname = selected[-1].name().split("_")[0]
        shapes = []
        for node in selected:
            shapes.extend([node for node in node.getChildren(ad=True, s=True) if pm.nodeType(node.name()) in include_type])
        transforms = [shape.getParent() for shape in shapes]
        if not transforms:
            _logger.warning("Invalid selection")
            return None
        result = pm.promptDialog(
            title='Create Set',
            message='Name:',
            button=['OK', 'Cancel'],
            defaultButton='OK',
            cancelButton='Cancel',
            dismissString='Cancel',
            text=pre_setname,
        )
        if result == 'OK':
            input_ = pm.promptDialog(query=True, text=True)
        else:
            _logger.warning("Set need a name")
            return None
        if pm.objExists("root_SETS"):
            root_set = pm.PyNode("root_SETS")
        else:
            pm.select(cl=True)
            root_set = pm.sets(n="root_SETS")
        if re.search(r'[A-Za-z0-9_]+(_SETS)', input_) is None:
            input_ = "%s_SET" % input_
        pm.select(cl=True)
        set_ = pm.sets(n=input_)
        set_.addMembers(transforms)
        pm.sets(root_set, fe=set_)
        pm.select(selected)
        _logger.info("%s" % set_)
        return set_
def createSet ( self ) : include_type = [ "mesh" , "aiStandIn" , "pgYetiMaya" ] selected = pm . selected ( ) pre_setname = selected [ - 1 ] . name ( ) . split ( "_" ) [ 0 ] shapes = [ ] for node in selected : shapes . extend ( [ node for node in node . getChildren ( ad = True , s = True ) if pm . nodeType ( node . name ( ) ) in include_type ] ) transforms = [ shape . getParent ( ) for shape in shapes ] if not transforms : _logger . warning ( "Invalid selection" ) return None result = pm . promptDialog ( title = 'Create Set' , message = 'Name:' , button = [ 'OK' , 'Cancel' ] , defaultButton = 'OK' , cancelButton = 'Cancel' , dismissString = 'Cancel' , text = pre_setname , ) if result == 'OK' : input_ = pm . promptDialog ( query = True , text = True ) else : _logger . warning ( "Set need a name" ) return None if pm . objExists ( "root_SETS" ) : root_set = pm . PyNode ( "root_SETS" ) else : pm . select ( cl = True ) root_set = pm . sets ( n = "root_SETS" ) if re . search ( r'[A-Za-z0-9_]+(_SETS)' , input_ ) is None : input_ = "%s_SET" % input_ pm . select ( cl = True ) set_ = pm . sets ( n = input_ ) set_ . addMembers ( transforms ) pm . sets ( root_set , fe = set_ ) pm . select ( selected ) _logger . info ( "%s" % set_ ) return set_
Create Set then put transform node selected.
Create Set then put transform node selected .
""" Create Set then put transform node selected. """ # GET SELECTED # Prompt Dialog # ROOT SET # CREATE SET
self