## ## script to change the image name in materials for helmet serial number ## for anthony appleyard ## july 2008 ## ## using selected item , get named materials , get image map of diffuse , change name , update material shader tree ## assumed NO materials that are not the numbers to change ## assumed a default material is allocated at the start with an image map in place ## import poser import string scn = poser.Scene() act = scn.CurrentActor() print act.Name() # debug line - ensure label prop is selected message = "Enter a number - maximum four digits " parentDialog = 1 dialog = poser.DialogTextEntry(parentDialog,message) dialog.Show() reply = dialog.Text() # check if entry is ok , numeric or space if len(reply) >=4: k = 0 while k<4: if reply[k] isdigit or reply[k] isspace): pass else: raise("Number entered is not valid - ending script") # mats = act.Materials() # get the materials for the label for mat in mats: # first get the digits for each material group if mat.Name().startswith("th"): mynum = reply[0] if mat.Name().startswith("h"): mynum = reply[1] if mat.Name().startswith("te"): mynum = reply[2] if mat.Name().startswith("u"): mynum = reply[3] # build the filename string if mynum == " ": mynum = "space" mystring = "runtime/textures/aa/numbers/mynum" # now set the image map st = mat.ShaderTree() # get the shader tree bn = st.Node(0) # get the root node di = bn.Input(0) # get the diffuse channel dn = di.InNode() # get whats connected to diffuse if dn.Type() == poser.kNodeTypeCodeIMAGEMAP(): # confirm its an image map node dni = dn.Input(0) # get the filename input dni.SetString(mystring) # set the filename string kNodeTypeCodeIMAGEMAP st.UpdatePreview() print "Done ! "