src/jmLightToolkit.py
def linkLightFilterToLights(self, filter_):
        """ Either create or get light filter then link it to lights.

            Args:
                filter_(str): Light filter that you want. 'aiLightBlocker', 'aiLightDecay', 'aiGobo'.
        """
        # Check
        if filter_ not in ["aiLightDecay", "aiLightBlocker", "aiGobo"]:
            _logger.error("'aiLightBlocker', 'aiLightDecay', 'aiGobo'")
            return None

        # Sort lights and filters
        lights_selected = []
        filter_selected = []
        for selected in pm.selected():
            if pm.nodeType(selected.name()) == "transform":
                if pm.nodeType(selected.getShape().name()) in self.lgt_types:
                    lights_selected.append(selected.getShape())

                elif pm.nodeType(selected.getShape().name()) == filter_:
                    filter_selected.append(selected.getShape())

            else:  # if selected != transform
                if pm.nodeType(selected.name()) in self.lgt_types:
                    lights_selected.append(selected)

                elif pm.nodeType(selected.name()) == filter_:
                    filter_selected.append(selected)

        # Return if no lights selected
        if not lights_selected:
            _logger.warning("No lights found.")
            return None

        # If filter is empty, create one
        if not filter_selected:
            filter_selected = [pm.createNode(filter_)]

        # Link filter to lights
        for filtr in filter_selected:
            try:
                transform_filter = filtr.getParent()
            except AttributeError:
                transform_filter = filtr

            for lgt in lights_selected:
                if (filtr not in lgt.inputs()) and (transform_filter not in lgt.inputs()):
                    i = 0
                    info = pm.connectionInfo("%s.aiFilters[%s]" % (lgt, i), id=True)

                    while info :
                        i += 1
                        info = pm.connectionInfo("%s.aiFilters[%s]" % (lgt, i), id=True)

                    node_filter = pm.PyNode("%s.message" % filtr)
                    node_lgt = pm.PyNode("%s.aiFilters[%s]" % (lgt, i))
                    node_filter >> node_lgt

        filter_name = [node.name() for node in filter_selected]
        _logger.info("filter : %s " % filter_name)
        return filter_selected
 Either create or get light filter then link it to lights.

            Args:
                filter_(str): Light filter that you want. 'aiLightBlocker', 'aiLightDecay', 'aiGobo'.
        
Either create or get light filter then link it to lights.
Either create or get light filter then link it to lights .
def linkLightFilterToLights(self, filter_):
        if filter_ not in ["aiLightDecay", "aiLightBlocker", "aiGobo"]:
            _logger.error("'aiLightBlocker', 'aiLightDecay', 'aiGobo'")
            return None
        lights_selected = []
        filter_selected = []
        for selected in pm.selected():
            if pm.nodeType(selected.name()) == "transform":
                if pm.nodeType(selected.getShape().name()) in self.lgt_types:
                    lights_selected.append(selected.getShape())
                elif pm.nodeType(selected.getShape().name()) == filter_:
                    filter_selected.append(selected.getShape())
            else:  
                if pm.nodeType(selected.name()) in self.lgt_types:
                    lights_selected.append(selected)
                elif pm.nodeType(selected.name()) == filter_:
                    filter_selected.append(selected)
        if not lights_selected:
            _logger.warning("No lights found.")
            return None
        if not filter_selected:
            filter_selected = [pm.createNode(filter_)]
        for filtr in filter_selected:
            try:
                transform_filter = filtr.getParent()
            except AttributeError:
                transform_filter = filtr
            for lgt in lights_selected:
                if (filtr not in lgt.inputs()) and (transform_filter not in lgt.inputs()):
                    i = 0
                    info = pm.connectionInfo("%s.aiFilters[%s]" % (lgt, i), id=True)
                    while info :
                        i += 1
                        info = pm.connectionInfo("%s.aiFilters[%s]" % (lgt, i), id=True)
                    node_filter = pm.PyNode("%s.message" % filtr)
                    node_lgt = pm.PyNode("%s.aiFilters[%s]" % (lgt, i))
                    node_filter >> node_lgt
        filter_name = [node.name() for node in filter_selected]
        _logger.info("filter : %s " % filter_name)
        return filter_selected
def linkLightFilterToLights ( self , filter_ ) : if filter_ not in [ "aiLightDecay" , "aiLightBlocker" , "aiGobo" ] : _logger . error ( "'aiLightBlocker', 'aiLightDecay', 'aiGobo'" ) return None lights_selected = [ ] filter_selected = [ ] for selected in pm . selected ( ) : if pm . nodeType ( selected . name ( ) ) == "transform" : if pm . nodeType ( selected . getShape ( ) . name ( ) ) in self . lgt_types : lights_selected . append ( selected . getShape ( ) ) elif pm . nodeType ( selected . getShape ( ) . name ( ) ) == filter_ : filter_selected . append ( selected . getShape ( ) ) else : if pm . nodeType ( selected . name ( ) ) in self . lgt_types : lights_selected . append ( selected ) elif pm . nodeType ( selected . name ( ) ) == filter_ : filter_selected . append ( selected ) if not lights_selected : _logger . warning ( "No lights found." ) return None if not filter_selected : filter_selected = [ pm . createNode ( filter_ ) ] for filtr in filter_selected : try : transform_filter = filtr . getParent ( ) except AttributeError : transform_filter = filtr for lgt in lights_selected : if ( filtr not in lgt . inputs ( ) ) and ( transform_filter not in lgt . inputs ( ) ) : i = 0 info = pm . connectionInfo ( "%s.aiFilters[%s]" % ( lgt , i ) , id = True ) while info : i += 1 info = pm . connectionInfo ( "%s.aiFilters[%s]" % ( lgt , i ) , id = True ) node_filter = pm . PyNode ( "%s.message" % filtr ) node_lgt = pm . PyNode ( "%s.aiFilters[%s]" % ( lgt , i ) ) node_filter >> node_lgt filter_name = [ node . name ( ) for node in filter_selected ] _logger . info ( "filter : %s " % filter_name ) return filter_selected
Either create or get light filter then link it to lights.
Either create or get light filter then link it to lights .
""" Either create or get light filter then link it to lights.

            Args:
                filter_(str): Light filter that you want. 'aiLightBlocker', 'aiLightDecay', 'aiGobo'.
        """ # Check # Sort lights and filters # if selected != transform # Return if no lights selected # If filter is empty, create one # Link filter to lights
self
filter_
Light filter that you want. 'aiLightBlocker', 'aiLightDecay', 'aiGobo'.
Light filter that you want . ' aiLightBlocker ' ' aiLightDecay ' ' aiGobo ' .