Tue, Nov 19, 7:40 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Getting/Setting Intensity for a light?


OberonRex ( ) posted Mon, 13 November 2023 at 11:50 AM · edited Tue, 19 November 2024 at 7:30 AM

I can write Python code to loop over the lights and tell if they're on or off. I can set them on or off. And I've just failed miserably at finding how to get and set the intensity. Sure looks like "Intensity" is the magic word, but I'm missing something.

For an individual light, I can access light.LightType, LightOn, SetLightOn, SetLightOff, but, sigh, I cannot find how to get/set intensity.

Has to be simple but I can't figure it out.

So -- what's the secret, eh?


OberonRex ( ) posted Mon, 13 November 2023 at 12:17 PM

Nevermind. Naturally, after "giving up" and asking, I found it.


bagginsbill ( ) posted Mon, 13 November 2023 at 12:20 PM

You grab the parameter from the actor and then you can use Value() or SetValue() to read and write it.

zTtbNWWMpwY0iBHeFnOwOLDlGMBZxeEQwOhUmOOz.png


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


OberonRex ( ) posted Mon, 13 November 2023 at 12:43 PM

Thanks!

And also thank you for your footnote about reply notifications. Useful to know.


Bastep ( ) posted Mon, 13 November 2023 at 12:46 PM

Its simple:

#----------------------------------------------------------------------------------
# DimLights.py
# Makes the light brighter or darker
#
# Date:             13.11.2023 19:31:50
# Letzte Aenderung: 13.11.2023 19:31:52
# Author:           Bastep
# Contact:          via Renderocity
#
# This is free to use.
#----------------------------------------------------------------------------------

import poser

def main():
    light = poser.Scene().CurrentActor() # Retrieves the selected Actor from the scene.
    if light.IsLight: # Is the Actor a light?
        intensity = light.Parameter('Intensity') # Retrieves the intensity parameter from the parameter list
        print(intensity.Value()) # Shows the current value
        intensity.SetValue(0.5) # Assigns the new value. The values refer to 1. 1 = 100% intensity
        print(intensity.Value()) # Shows the new value

if __name__ == "__main__":
    main()




Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.