Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
You can set a Texturemap with SetTextureMapFileName to a material as base-texture. But not to a Node.
All Nodes follow the same rules. They have Inputs and Outputs where something can connect to (even values or textures). Inputs and outputs are arranged as lists. See "PoserPython Methods Manual" in your Poser directory.
Normally you have to search or determine the index of an input/output. But fortunately "Image_Source" is the first entry in the node "Image_Map".
< Node >.Inputs()[0].InNode().SetString(< Path >)
Manual says to "SetString": ** SetString** Explanation Set the string value. In this version of Poser, this is the path of a texture or movie file. Arguments Enter the path name for the desired texture or movie file.
Sure, you need to know something about the image you want to change. A path or filename will do if it is unique.
Here is a sample-search:
try:
# I need to do this to make my editor happy
import poser
except ImportError:
poser = None
import re
def find_image(node, name="Image_Source", value="myImage.*"):
if node is None:
return None
if node.Type() == poser.kNodeTypeCodeIMAGEMAP:
test = re.compile(value)
for inp in node.Inputs():
v = inp.Value()
if isinstance(v, basestring) and test.search(v):
return node
result = find_image(inp.InNode())
if result is not None:
return result
return None
sc = poser.Scene()
for mat in sc.CurrentFigure().Materials():
for shadernode in mat.ShaderTree().Nodes():
# change value to what should be part of the
# path you search for
node = find_image(shadernode, value="Mask")
if node is not None:
print node.Name()
print node.InputByInternalName("Image_Source").Value()
This should give you an idea how to solve your problem.
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.
Hi folks,I'm trying to change the texture of a node in the Shader Tree but I'm having trouble, maybe someone can help me This is my code: