Thu, Jan 9, 6:39 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: Apply a graphic (Image Map) to the 'diffuse color'


timarender ( ) posted Fri, 13 July 2012 at 6:13 AM · edited Mon, 02 December 2024 at 5:53 PM

Please excuse me if I am using the wrong terminology.

I want to apply a graphic which is not a Material in the Library. Manually, I would open the Material room, create an 'Image Map', choose the selected graphic; and then apply the image map to Diffuse Color.

Using script, I could use "LoadMaterialCollection" to apply a material from the Library. But that does not work with a graphic outside the Library, eg:  d:tempa.jpg

Can anyone point me in the right direction, please.

Alternatively; is there a scripting way to take a bunch of graphic file and convert them into materials?

I appreciate all this may involve itinerating through materials etc. But, I am really getting lost in the Poser Python manual.

Thanks for any assistance.


millighost ( ) posted Fri, 13 July 2012 at 8:42 AM

It should roughly look like this:

import poser

scene = poser.Scene ()

use the currently selected actor

actor = scene.CurrentActor ()

use the first material that is there:

material = actor.Materials ()[0]

manipulate the shader tree...

shader = material.ShaderTree ()

create a new image map

image_map = shader.CreateNode (poser.kNodeTypeCodeIMAGEMAP)

set the path of the image_map

path_input = image_map.InputByInternalName ("Image_Source")
path_input.SetString ("d:my_image.png")

connect the nodes

surface = shader.NodeByInternalName ("PoserSurface")
shader.AttachTreeNodes (surface, "Diffuse_Color", image_map)


timarender ( ) posted Fri, 13 July 2012 at 9:28 AM

That was very helpful. Thank you very much for taking the time to assist me.


bagginsbill ( ) posted Fri, 13 July 2012 at 11:28 AM · edited Fri, 13 July 2012 at 11:32 AM

Even easier with matmatic. It's a one-liner.

for name in os.listdir("some folder here"): if name.endswith(".jpg"): outputs += ["=Material[%s]" % name, Surface(ImageMap(name), .8)]

Of course I'm just showing off and that's not really a finished script as there would be some manipulation of the path name. But the part of making the material for each image file is correct:

Surface(ImageMap(imageFileName), .8)


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)


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.