Forum: Poser Python Scripting


Subject: Useful Code Snippets

structure opened this issue on Jun 27, 2019 ยท 94 posts


structure posted Wed, 12 August 2020 at 8:28 AM Forum Coordinator

A simple lights class

class poserlights:
    def processlights( self, code = 0 ):
        if not isinstance( code, int):
            return

        lights = scene.Lights()
    
        if not code > 1:
            # LightsOnOff
            [light.SetLightOn(code) for light in lights]
        
        elif code == 2:
            # toggle lights
            [light.SetLightOn(not light.LightOn()) for light in lights]
    
        else:
            # Delete Lights
            [light.Delete() for light in lights]

        scene.DrawAll()

import poser
scene = poser.Scene()
l = poserlights()

# turn lights off
l.processlights(0)

# turn lights on
l.processlights(1)

# toggle lights
l.processlights(2)

# delete lights
l.processlights(3) (any number above 2)

Locked Out