Mon, Jan 27, 7:43 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 Dec 02 3:16 pm)

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: Maybe we can learn together


PhilC ( ) posted Sun, 04 February 2001 at 10:19 AM · edited Mon, 27 January 2025 at 7:29 AM

I did some basic programming way way back when a window was a hole in the wall you looked through. I can even remember adding holes to punched paper tape to try and make corrections. With the advent of the PC I went on to other things, mainly graphics, and let the programming slide. I've always wanted to get back into it and Python scripting within PPP looks like a good way to do it. My guess is that there are others out there who also would like a stab at it. Hopefully we can learn together.
I am going to try and write a script (is that the right word?) to make Poser set all of a model's object materials to white and the highlight, ambient and reflective materials to black. I regularly have to do this manually so I guess it would be a useful thing to do.
As I type this I do not know where to start. I'm at ground zero. I'm heading for the Python tutorials. If you know the answer, don't tell me.... but please lead me. Kinda like the detective novel, don't tell me who did it just point out the clues :)
philc_agatha_white_on_black.jpg


JeffH ( ) posted Sun, 04 February 2001 at 11:32 AM

That sounds like a very useful script indeed. I don't have my brain fully wrapped around the concepts either, my plan is much like yours. The PP has lots of sample scripts you can play with and edit.


jbrugion ( ) posted Sun, 04 February 2001 at 2:16 PM

Post any questions/problems to this forum and I for one will try and help. Recommend www.python.org for tutorials and background information. For books I personally like "The Quick Python Book" by Harms and McDonald and if you want to do gui's then you have to have "Python and Tkinter Programming" by Grayson. Would heartily recommend downloading Python 2.0 or 1.5.2 and have it able to separately so that you can tutorials and learning and gui debugging. There are also a couple of freeware editors out there that recognize the special needs of Python. Check out http://www.scintilla.org Also check out http://www.coriolis.com/store/product.asp?sku=1418 as there will be a book coming out soon that should have a good Poser-Python tutorial in it ( at least it will if I can finish it in time :-)) ) As for leads check out the "Inventory" script under the "Material Mods" tab on the Python Scripts dialog supplied with the propack. FYI, tabs are significant in Python: C/C++: for( i=0 ; i < 20; i=i+1) { do something } Python for i in range(20) do something


jbrugion ( ) posted Sun, 04 February 2001 at 2:18 PM

!@#$%%^&&*((&^%$$#@!!!!!!! last line should be: Python for i in range(20): tab do something


Mason ( ) posted Sun, 04 February 2001 at 2:43 PM

Sounds like a good idea. I've been looking over the instruction set available and theres a script I want to write right off the bat. Basically, in the script, all figures in the world are rendered as low detailed poly/boxes until you select one. Then its render mode is set to high detail. This way only the figure you're focused on needs to be textured and high detail while editing increasing machine speed. I always wished Poser had that ability and apparently you can set on screen render attributes for seperate actors.


bushi ( ) posted Sun, 04 February 2001 at 3:05 PM

The two books I've found to be most useful so far are: Learning Python - Mark Lutz and David Ascher Programming Python - Mark Lutz Both are published by O'Reilly and are available at their website. I think you can also get them through Amazon.com. I'd also suggest getting a copy of WinPython. It's a pretty good learning tool. Be warned though TkInter doesn't work correctly when called from WinPython.


bushi ( ) posted Sun, 04 February 2001 at 3:44 PM

Sorry, WinPython should read PythonWin. :-)


PhilC ( ) posted Sun, 04 February 2001 at 4:19 PM

OK, wading through molasses here. This is a sketchy first shot. No it does not work but I have to start somewhere :) #------------------------------- Start by importing what I assume is a bunch of prewritten goodies that may prove useful #------------------------------- import poser #------------------------------- I need to define that I'm working on the currently selected figure #-------------------------------- scene = poser.Scene() actor = scene.CurrentActor() figure = actor.ItsFigure() #------------------------------ Now to go through the materials list and change the values. RGB is allowed to have value from zero to one so I'm guessing that one must be white #------------------------------ materials = figure.Materials() ________for material in materials: ________set the material.DiffuseColor (1, 1, 1) #------------------------------ Redraw the scene #------------------------------ scene.DrawAll() #------------------------------ OK I know that syntax is out of the window but am I going in the right direction? philc_agatha_white_on_black.jpg


bushi ( ) posted Sun, 04 February 2001 at 4:42 PM

Yes, it looks like you're off to a good start. Just remember when you set up your loops that the start and end are marked by the indentation.


PhilC ( ) posted Sun, 04 February 2001 at 7:16 PM

file_145884.gif

Oh YEAH!!!!!!!! it worked :)) OK I have to admit it did some guessing and I was lucky that it was correct. I've uploaded to the freestuff Poser Propack section. Although I have set the colours to black or white simple editing will enable other colours. Maybe I'll see if I can wright an input routine so that the colour can be defined. Oh and if no figure is selected it throws a wobbly, I may have to attend to that also. Thanks for the input ... its been a fun day :) [![philc_agatha_white_on_black.jpg](http://www.philc.net/images/logos/philc_agatha_white_on_black.jpg)](http://www.philc.net)


JeffH ( ) posted Sun, 04 February 2001 at 7:23 PM

Cool.


bushi ( ) posted Sun, 04 February 2001 at 7:37 PM

Phil - Take a look at the beginning lines of the loop in either of the two scripts I've posted. They will give you a list of all the figures in a scene. You can then use that list as the basis for you're selections or you could set up the script to do the materials change for all the figures.


PhilC ( ) posted Sun, 04 February 2001 at 7:58 PM

Thanks, yes. I think I needed something that said if no figure was selected PRINT "First select a figure". I had not found that variable.
What is the instruction set you refer to? I have a file called PoserPython.txt is that the same thing?
philc_agatha_white_on_black.jpg


poserpro ( ) posted Mon, 05 February 2001 at 4:42 AM

how about a random materials, I like to use the raodomize function to get different diffuseColor ( and/or ambientColor....) on the figure. BTW, as far as I know trueSpace ( and Alice 3D, www. alice.org) also uses python as its script, does any one know if their scripts would help.


poserpro ( ) posted Mon, 05 February 2001 at 5:00 AM

Done, the RandomObjectMaterials.py is complete and it gives the selected figure random diffuseColor for all materials. I rewrote from PhilC's Materials py.


poserpro ( ) posted Mon, 05 February 2001 at 5:03 AM

Done, randomAmbientMaterials.py Now she glows :)


poserpro ( ) posted Mon, 05 February 2001 at 5:08 AM

Done, ResetMaterial.py to reset ambient back to black ( 0, 0, 0) and diffuse to gray( .5, .5, .5 )


poserpro ( ) posted Mon, 05 February 2001 at 5:13 AM

I wonder if we can write a random RandomTextureMap.py so that the selected figure will be mapped with different designated textures in random order. With the randomHeadMT.py as in other message i posted in this Python forum, this feature can possibily create many random new figures.


poserpro ( ) posted Mon, 05 February 2001 at 5:15 AM

the random py can be used for the figure's full body MT so that we can get many random new figures, much like the creature creator's randomize feature.


CharlieBrown ( ) posted Mon, 05 February 2001 at 8:03 AM

I don't have the PPP yet - would it be possible to set a script that took user input, so you could set ALL of a figures colors to whatever you wanted; i.e. Set the main parts one color, highlights another, reflective another, and ambient colors to a fourth color, input by the user? Would that even be useful?


PhilC ( ) posted Mon, 05 February 2001 at 8:30 AM

I'm trying to get that modification to work now. Unfortunately this has a bug somewhere that I can not see:-
R = input("Red 0 = dark, 1 = light" )
G = input("Green 0 = dark, 1 = light" )
B = input("Blue 0 = dark, 1 = light ")

materials = figure.Materials()

for material in materials:

TABmaterial.SetDiffuseColor (R, G, B)
Any ideas why?
philc_agatha_white_on_black.jpg


jbrugion ( ) posted Mon, 05 February 2001 at 10:36 AM

What error message are you getting when you run or is it just not giving you the right results? Can you post the full script somewhere?


PhilC ( ) posted Mon, 05 February 2001 at 10:58 AM

Thanks, yes. Click here for the script as it now stands. Details in the readme.
philc_agatha_white_on_black.jpg


poserpro ( ) posted Mon, 05 February 2001 at 12:11 PM

Not Found?


tjs61822 ( ) posted Mon, 05 February 2001 at 12:28 PM

I'm not sure if this is a problem, but I noticed you had a space between "light" and the closing quotes on the blue line B = input("Blue 0 = dark, 1 = light ")


ScottA ( ) posted Mon, 05 February 2001 at 1:24 PM

Phil. I really like the way you have everything heavily commented. That's the only way the rest of us are going to lean this. Keep doing that please. It's helping me a lot. ScottA


steveshanks ( ) posted Mon, 05 February 2001 at 3:22 PM

Phil thanks for that mate it works a treat and will save a lot of time........Steve


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.