src/jmLightToolkit.py
def deleteSafelyLightFilter(self, filters):
        """ Delete safely unused Arnold light filter.

            Args:
                filters(dict): Filter type and List of disconnected/null filters that you want to delete.
        """
        # Check input attributes
        if filters["type"] not in ["aiLightDecay", "aiLightBlocker"]:
            _logger.error("'aiLightDecay' or 'aiLightBlocker'")
            return None

        if not filters["disconnected"] and not filters["null"]:
            _logger.warning("No light filters found.")
            return None

        # Disconnect null filters from light
        for lightfilter in filters["null"]:
            # Get connected lights
            lights = pm.connectionInfo("%s.message" % lightfilter, dfs=True)
            lights = [connection for connection in lights if "aiFilters" in connection]

            for light in lights :
                light_node = pm.PyNode(light.split(".")[0])
                num_filter = len( pm.PyNode("%s.aiFilters" % light_node).inputs() )
                index = int( re.findall(r"\[[0-9]+\]", light)[0].strip("[]") )

                i = 0
                while (i < num_filter):
                    if i == index:
                        pm.PyNode("%s.message" % lightfilter) // pm.PyNode(pm.PyNode("%s.aiFilters[%s]" % (light_node, i)))

                    if i > index:
                        other_filter = pm.connectionInfo("%s.aiFilters[%s]" % (light_node, i), sfd=True)
                        other_filter = pm.PyNode(other_filter)
                        other_filter // pm.PyNode("%s.aiFilters[%s]" % (light_node, i))
                        other_filter >> pm.PyNode("%s.aiFilters[%s]" % (light_node, i - 1))

                    i += 1

        # Delete unused and null filters
        deleted_filters = filters["disconnected"] + filters["null"]
        for lightfilter in deleted_filters:
            if pm.objExists(lightfilter):
                try:
                    pm.delete(lightfilter.getParent())
                except AttributeError :
                    pm.delete(lightfilter)

        _logger.info("Safely deleted {0} : {1}".format(filters["type"], deleted_filters))
        return deleted_filters
 Delete safely unused Arnold light filter.

            Args:
                filters(dict): Filter type and List of disconnected/null filters that you want to delete.
        
Delete safely unused Arnold light filter.
Delete safely unused Arnold light filter .
def deleteSafelyLightFilter(self, filters):
        if filters["type"] not in ["aiLightDecay", "aiLightBlocker"]:
            _logger.error("'aiLightDecay' or 'aiLightBlocker'")
            return None
        if not filters["disconnected"] and not filters["null"]:
            _logger.warning("No light filters found.")
            return None
        for lightfilter in filters["null"]:
            lights = pm.connectionInfo("%s.message" % lightfilter, dfs=True)
            lights = [connection for connection in lights if "aiFilters" in connection]
            for light in lights :
                light_node = pm.PyNode(light.split(".")[0])
                num_filter = len( pm.PyNode("%s.aiFilters" % light_node).inputs() )
                index = int( re.findall(r"\[[0-9]+\]", light)[0].strip("[]") )
                i = 0
                while (i < num_filter):
                    if i == index:
                        pm.PyNode("%s.message" % lightfilter) // pm.PyNode(pm.PyNode("%s.aiFilters[%s]" % (light_node, i)))
                    if i > index:
                        other_filter = pm.connectionInfo("%s.aiFilters[%s]" % (light_node, i), sfd=True)
                        other_filter = pm.PyNode(other_filter)
                        other_filter // pm.PyNode("%s.aiFilters[%s]" % (light_node, i))
                        other_filter >> pm.PyNode("%s.aiFilters[%s]" % (light_node, i - 1))
                    i += 1
        deleted_filters = filters["disconnected"] + filters["null"]
        for lightfilter in deleted_filters:
            if pm.objExists(lightfilter):
                try:
                    pm.delete(lightfilter.getParent())
                except AttributeError :
                    pm.delete(lightfilter)
        _logger.info("Safely deleted {0} : {1}".format(filters["type"], deleted_filters))
        return deleted_filters
def deleteSafelyLightFilter ( self , filters ) : if filters [ "type" ] not in [ "aiLightDecay" , "aiLightBlocker" ] : _logger . error ( "'aiLightDecay' or 'aiLightBlocker'" ) return None if not filters [ "disconnected" ] and not filters [ "null" ] : _logger . warning ( "No light filters found." ) return None for lightfilter in filters [ "null" ] : lights = pm . connectionInfo ( "%s.message" % lightfilter , dfs = True ) lights = [ connection for connection in lights if "aiFilters" in connection ] for light in lights : light_node = pm . PyNode ( light . split ( "." ) [ 0 ] ) num_filter = len ( pm . PyNode ( "%s.aiFilters" % light_node ) . inputs ( ) ) index = int ( re . findall ( r"\[[0-9]+\]" , light ) [ 0 ] . strip ( "[]" ) ) i = 0 while ( i < num_filter ) : if i == index : pm . PyNode ( "%s.message" % lightfilter ) // pm . PyNode ( pm . PyNode ( "%s.aiFilters[%s]" % ( light_node , i ) ) ) if i > index : other_filter = pm . connectionInfo ( "%s.aiFilters[%s]" % ( light_node , i ) , sfd = True ) other_filter = pm . PyNode ( other_filter ) other_filter // pm . PyNode ( "%s.aiFilters[%s]" % ( light_node , i ) ) other_filter >> pm . PyNode ( "%s.aiFilters[%s]" % ( light_node , i - 1 ) ) i += 1 deleted_filters = filters [ "disconnected" ] + filters [ "null" ] for lightfilter in deleted_filters : if pm . objExists ( lightfilter ) : try : pm . delete ( lightfilter . getParent ( ) ) except AttributeError : pm . delete ( lightfilter ) _logger . info ( "Safely deleted {0} : {1}" . format ( filters [ "type" ] , deleted_filters ) ) return deleted_filters
Delete safely unused Arnold light filter.
Delete safely unused Arnold light filter .
""" Delete safely unused Arnold light filter.

            Args:
                filters(dict): Filter type and List of disconnected/null filters that you want to delete.
        """ # Check input attributes # Disconnect null filters from light # Get connected lights # Delete unused and null filters
self
filters
Filter type and List of disconnected/null filters that you want to delete.
Filter type and List of disconnected / null filters that you want to delete .