Wed, Nov 20, 4:51 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: Help needed with a script to witch off all lights


jenay ( ) posted Sat, 12 July 2008 at 6:51 AM · edited Wed, 20 November 2024 at 4:49 AM

I am no longer sure, if it can be done with Poser5. I want to switch off
all lights of a given scene, without deleting nor changing the values and - optional -
to switch them on again.
here is a small script that does the job, but it's not exactly what I
envisioned. If I set all intensity values to 0, I cannot restore the original intensity
settings.
---8<---

Set Intensity of All Lights to 0

import poser

scene=poser.Scene()
lights=scene.Lights()
for light in lights:
 actor = scene.Actor(light.Name())
 print(actor)

for dials in actor.Parameters():

print (dials.Name())

 actor.Parameter("Intensity").SetValue(0)
scene.DrawAll()
---8<---

I found the SetOnOff method, but for the lights it is not what I need.
It only switches the "faked" light objects on and off, but not the lights
themselves.

some tips appreciated :)

 


nruddock ( ) posted Sat, 12 July 2008 at 7:29 AM · edited Sat, 12 July 2008 at 7:30 AM

P5 lacks a method to just turn lights on and off without affecting the Intensity (SetLightOn(x) was introduced in P6).

I suspect that the only way to achieve what you want will be to write a pose file for the current light intensities, so that you can later restore them.
This is more complicated than what would be needed for P6 and above, so you may want to look at ockham's LightPanel script to see how that sort of thing is done.


markschum ( ) posted Sat, 12 July 2008 at 10:00 AM

I would write out the light values to a temp file , then you can read them back in later.

writing a file

myfile = "c:templightvalues.txt"
fo = file("myfile,"w")
for light in lights:
      write light.value + "n"

fo.close()
#reading a file
myfile = "c:templightvalues.txt"
fi = file(myfile,"r")
for line in fi :

set light to value from line

fi.close()


jenay ( ) posted Sat, 12 July 2008 at 12:58 PM

Hi All,
thank you for the advice :)

write out to a temp file would do the trick :)

 


markschum ( ) posted Sat, 12 July 2008 at 1:16 PM

There are other ways you could try, but the file method seems easy to implement .


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.