src/jmLightToolkit.py
def displayBlocker(self):
        """ Create 'aiLightBlocker' display from lights selected. """

        # Get Blockers
        blockers = []
        for sel in pm.selected():
            if pm.nodeType(sel.name()) == "transform":
                if pm.nodeType(sel.getShape().name()) == "aiLightBlocker":
                    blockers.append(sel)

            else:
                if pm.nodeType(sel.name()) == "aiLightBlocker":
                    blockers.append(sel.getParent())

        # Abort if not blockers selected
        if not blockers:
            _logger.warning("No Blockers found")
            return None

        # Rename all blockers
        for blocker in pm.ls(type="aiLightBlocker"):
            blocker_name = blocker.name()
            pm.rename(blocker.getParent(), "%s_C_001_AILB" % blocker_name)

        # Create mtoa utils grp
        utils_grp = self._eitherCreateGetNode("grp", self.mtoa_utils_grp)
        display_blocker_grp = self._eitherCreateGetNode("grp", self.display_blocker_grp)
        pm.parent(display_blocker_grp, utils_grp)

        # Create shader
        if not pm.objExists("displayBlocker_SHAD"):
            shader = pm.shadingNode("lambert", n="displayBlocker_SHAD", asShader=True)
            shading_group= pm.sets(renderable=True, n="displayBlocker_SDEG", noSurfaceShader=True, empty=True)
            pm.connectAttr('%s.outColor' % shader, '%s.surfaceShader' % shading_group)
            shader.color.set(0.8, 0.0, 0.2)
            shader.transparency.set(0.9, 0.9, 0.9)
            shader.translucence.set(1)
        else:
            shader = pm.PyNode("displayBlocker_SHAD")

        # Process
        out = []
        for blocker in blockers:
            #  query type of all blocker
            blocker_type = pm.getAttr("%s.geometryType" % blocker)
            display_mesh_name = re.sub(
                r"^(?P<lightname>[A-Za-z0-9]+)(?P<under>[_])(?P<utility>[a-zA-Z]*)(?P<left>[A-Za-z0-9_]+)$",
                r"\g<lightname>\g<under>displayBlocker\g<left>",
                blocker.name())

            if pm.objExists(display_mesh_name):
                continue

            # create Mesh
            if blocker_type == 0 :
                display_mesh = pm.polyCube(n=display_mesh_name)[0]

            elif blocker_type == 1 :
                display_mesh = pm.polySphere(r=0.5, sh=16, sa=16, n=display_mesh_name)[0]

            elif blocker_type == 2 :
                display_mesh = pm.polyCube( d=1, w=1, h=0.01, n=display_mesh_name)[0]
                pm.setAttr ( "%s.rx" %pm.ls(sl=True)[0], 90 )
                pm.makeIdentity ( pm.ls(sl=True)[0], apply=True, t=1, r=1, s=1, n=0, pn=1 )

            else :
                display_mesh = pm.polyCylinder(h=1, r=0, sa=16, n=display_mesh_name)[0]

            # Match Pivot
            piv_x, piv_y, piv_z, _, _, _ = pm.xform(blocker, q=True, piv=True)
            pm.xform(display_mesh, piv=(piv_x, piv_y, piv_z))

            # Assign shader
            pm.select(display_mesh)
            pm.hyperShade(assign=shader)

            # set attr
            display_mesh_shape = display_mesh.getShape()
            display_mesh_shape.attr("castsShadows").set(0)
            display_mesh_shape.attr("receiveShadows").set(0)
            display_mesh_shape.attr("motionBlur").set(0)
            display_mesh_shape.attr("primaryVisibility").set(0)
            display_mesh_shape.attr("smoothShading").set(0)
            display_mesh_shape.attr("visibleInReflections").set(0)
            display_mesh_shape.attr("visibleInRefractions").set(0)
            display_mesh_shape.attr("doubleSided").set(0)
            display_mesh_shape.attr("aiOpaque").set(0)
            display_mesh_shape.attr("aiVisibleInDiffuseReflection").set(0)
            display_mesh_shape.attr("aiVisibleInSpecularReflection").set(0)
            display_mesh_shape.attr("aiVisibleInDiffuseTransmission").set(0)
            display_mesh_shape.attr("aiVisibleInSpecularTransmission").set(0)
            display_mesh_shape.attr("aiSelfShadows").set(0)

            pm.parent(display_mesh, display_blocker_grp)

            pm.pointConstraint(blocker, display_mesh)
            pm.orientConstraint(blocker, display_mesh)
            pm.scaleConstraint(blocker, display_mesh)

            display_mesh.overrideEnabled.set(1)
            display_mesh.overrideDisplayType.set(2)

            out.append(display_mesh)

        if out:
            _logger.info("Display Light Blocker success" % ([lgt.name() for lgt in out]))
        else:
            _logger.info("No 'aiLightBlocker' display created")

        self.__displayBlockerCSS()
        return out
 Create 'aiLightBlocker' display from lights selected. 
Create 'aiLightBlocker' display from lights selected.
Create ' aiLightBlocker ' display from lights selected .
def displayBlocker(self):
        blockers = []
        for sel in pm.selected():
            if pm.nodeType(sel.name()) == "transform":
                if pm.nodeType(sel.getShape().name()) == "aiLightBlocker":
                    blockers.append(sel)
            else:
                if pm.nodeType(sel.name()) == "aiLightBlocker":
                    blockers.append(sel.getParent())
        if not blockers:
            _logger.warning("No Blockers found")
            return None
        for blocker in pm.ls(type="aiLightBlocker"):
            blocker_name = blocker.name()
            pm.rename(blocker.getParent(), "%s_C_001_AILB" % blocker_name)
        utils_grp = self._eitherCreateGetNode("grp", self.mtoa_utils_grp)
        display_blocker_grp = self._eitherCreateGetNode("grp", self.display_blocker_grp)
        pm.parent(display_blocker_grp, utils_grp)
        if not pm.objExists("displayBlocker_SHAD"):
            shader = pm.shadingNode("lambert", n="displayBlocker_SHAD", asShader=True)
            shading_group= pm.sets(renderable=True, n="displayBlocker_SDEG", noSurfaceShader=True, empty=True)
            pm.connectAttr('%s.outColor' % shader, '%s.surfaceShader' % shading_group)
            shader.color.set(0.8, 0.0, 0.2)
            shader.transparency.set(0.9, 0.9, 0.9)
            shader.translucence.set(1)
        else:
            shader = pm.PyNode("displayBlocker_SHAD")
        out = []
        for blocker in blockers:
            blocker_type = pm.getAttr("%s.geometryType" % blocker)
            display_mesh_name = re.sub(
                r"^(?P<lightname>[A-Za-z0-9]+)(?P<under>[_])(?P<utility>[a-zA-Z]*)(?P<left>[A-Za-z0-9_]+)$",
                r"\g<lightname>\g<under>displayBlocker\g<left>",
                blocker.name())
            if pm.objExists(display_mesh_name):
                continue
            if blocker_type == 0 :
                display_mesh = pm.polyCube(n=display_mesh_name)[0]
            elif blocker_type == 1 :
                display_mesh = pm.polySphere(r=0.5, sh=16, sa=16, n=display_mesh_name)[0]
            elif blocker_type == 2 :
                display_mesh = pm.polyCube( d=1, w=1, h=0.01, n=display_mesh_name)[0]
                pm.setAttr ( "%s.rx" %pm.ls(sl=True)[0], 90 )
                pm.makeIdentity ( pm.ls(sl=True)[0], apply=True, t=1, r=1, s=1, n=0, pn=1 )
            else :
                display_mesh = pm.polyCylinder(h=1, r=0, sa=16, n=display_mesh_name)[0]
            piv_x, piv_y, piv_z, _, _, _ = pm.xform(blocker, q=True, piv=True)
            pm.xform(display_mesh, piv=(piv_x, piv_y, piv_z))
            pm.select(display_mesh)
            pm.hyperShade(assign=shader)
            display_mesh_shape = display_mesh.getShape()
            display_mesh_shape.attr("castsShadows").set(0)
            display_mesh_shape.attr("receiveShadows").set(0)
            display_mesh_shape.attr("motionBlur").set(0)
            display_mesh_shape.attr("primaryVisibility").set(0)
            display_mesh_shape.attr("smoothShading").set(0)
            display_mesh_shape.attr("visibleInReflections").set(0)
            display_mesh_shape.attr("visibleInRefractions").set(0)
            display_mesh_shape.attr("doubleSided").set(0)
            display_mesh_shape.attr("aiOpaque").set(0)
            display_mesh_shape.attr("aiVisibleInDiffuseReflection").set(0)
            display_mesh_shape.attr("aiVisibleInSpecularReflection").set(0)
            display_mesh_shape.attr("aiVisibleInDiffuseTransmission").set(0)
            display_mesh_shape.attr("aiVisibleInSpecularTransmission").set(0)
            display_mesh_shape.attr("aiSelfShadows").set(0)
            pm.parent(display_mesh, display_blocker_grp)
            pm.pointConstraint(blocker, display_mesh)
            pm.orientConstraint(blocker, display_mesh)
            pm.scaleConstraint(blocker, display_mesh)
            display_mesh.overrideEnabled.set(1)
            display_mesh.overrideDisplayType.set(2)
            out.append(display_mesh)
        if out:
            _logger.info("Display Light Blocker success" % ([lgt.name() for lgt in out]))
        else:
            _logger.info("No 'aiLightBlocker' display created")
        self.__displayBlockerCSS()
        return out
def displayBlocker ( self ) : blockers = [ ] for sel in pm . selected ( ) : if pm . nodeType ( sel . name ( ) ) == "transform" : if pm . nodeType ( sel . getShape ( ) . name ( ) ) == "aiLightBlocker" : blockers . append ( sel ) else : if pm . nodeType ( sel . name ( ) ) == "aiLightBlocker" : blockers . append ( sel . getParent ( ) ) if not blockers : _logger . warning ( "No Blockers found" ) return None for blocker in pm . ls ( type = "aiLightBlocker" ) : blocker_name = blocker . name ( ) pm . rename ( blocker . getParent ( ) , "%s_C_001_AILB" % blocker_name ) utils_grp = self . _eitherCreateGetNode ( "grp" , self . mtoa_utils_grp ) display_blocker_grp = self . _eitherCreateGetNode ( "grp" , self . display_blocker_grp ) pm . parent ( display_blocker_grp , utils_grp ) if not pm . objExists ( "displayBlocker_SHAD" ) : shader = pm . shadingNode ( "lambert" , n = "displayBlocker_SHAD" , asShader = True ) shading_group = pm . sets ( renderable = True , n = "displayBlocker_SDEG" , noSurfaceShader = True , empty = True ) pm . connectAttr ( '%s.outColor' % shader , '%s.surfaceShader' % shading_group ) shader . color . set ( 0.8 , 0.0 , 0.2 ) shader . transparency . set ( 0.9 , 0.9 , 0.9 ) shader . translucence . set ( 1 ) else : shader = pm . PyNode ( "displayBlocker_SHAD" ) out = [ ] for blocker in blockers : blocker_type = pm . getAttr ( "%s.geometryType" % blocker ) display_mesh_name = re . sub ( r"^(?P<lightname>[A-Za-z0-9]+)(?P<under>[_])(?P<utility>[a-zA-Z]*)(?P<left>[A-Za-z0-9_]+)$" , r"\g<lightname>\g<under>displayBlocker\g<left>" , blocker . name ( ) ) if pm . objExists ( display_mesh_name ) : continue if blocker_type == 0 : display_mesh = pm . polyCube ( n = display_mesh_name ) [ 0 ] elif blocker_type == 1 : display_mesh = pm . polySphere ( r = 0.5 , sh = 16 , sa = 16 , n = display_mesh_name ) [ 0 ] elif blocker_type == 2 : display_mesh = pm . polyCube ( d = 1 , w = 1 , h = 0.01 , n = display_mesh_name ) [ 0 ] pm . setAttr ( "%s.rx" % pm . ls ( sl = True ) [ 0 ] , 90 ) pm . makeIdentity ( pm . ls ( sl = True ) [ 0 ] , apply = True , t = 1 , r = 1 , s = 1 , n = 0 , pn = 1 ) else : display_mesh = pm . polyCylinder ( h = 1 , r = 0 , sa = 16 , n = display_mesh_name ) [ 0 ] piv_x , piv_y , piv_z , _ , _ , _ = pm . xform ( blocker , q = True , piv = True ) pm . xform ( display_mesh , piv = ( piv_x , piv_y , piv_z ) ) pm . select ( display_mesh ) pm . hyperShade ( assign = shader ) display_mesh_shape = display_mesh . getShape ( ) display_mesh_shape . attr ( "castsShadows" ) . set ( 0 ) display_mesh_shape . attr ( "receiveShadows" ) . set ( 0 ) display_mesh_shape . attr ( "motionBlur" ) . set ( 0 ) display_mesh_shape . attr ( "primaryVisibility" ) . set ( 0 ) display_mesh_shape . attr ( "smoothShading" ) . set ( 0 ) display_mesh_shape . attr ( "visibleInReflections" ) . set ( 0 ) display_mesh_shape . attr ( "visibleInRefractions" ) . set ( 0 ) display_mesh_shape . attr ( "doubleSided" ) . set ( 0 ) display_mesh_shape . attr ( "aiOpaque" ) . set ( 0 ) display_mesh_shape . attr ( "aiVisibleInDiffuseReflection" ) . set ( 0 ) display_mesh_shape . attr ( "aiVisibleInSpecularReflection" ) . set ( 0 ) display_mesh_shape . attr ( "aiVisibleInDiffuseTransmission" ) . set ( 0 ) display_mesh_shape . attr ( "aiVisibleInSpecularTransmission" ) . set ( 0 ) display_mesh_shape . attr ( "aiSelfShadows" ) . set ( 0 ) pm . parent ( display_mesh , display_blocker_grp ) pm . pointConstraint ( blocker , display_mesh ) pm . orientConstraint ( blocker , display_mesh ) pm . scaleConstraint ( blocker , display_mesh ) display_mesh . overrideEnabled . set ( 1 ) display_mesh . overrideDisplayType . set ( 2 ) out . append ( display_mesh ) if out : _logger . info ( "Display Light Blocker success" % ( [ lgt . name ( ) for lgt in out ] ) ) else : _logger . info ( "No 'aiLightBlocker' display created" ) self . __displayBlockerCSS ( ) return out
Create 'aiLightBlocker' display from lights selected.
Create ' aiLightBlocker ' display from lights selected .
""" Create 'aiLightBlocker' display from lights selected. """ # Get Blockers # Abort if not blockers selected # Rename all blockers # Create mtoa utils grp # Create shader # Process #  query type of all blocker # create Mesh # Match Pivot # Assign shader # set attr
self