Forum: Poser Python Scripting


Subject: Trying to add Spots node to displacement - 3 questions

parrotdolphin opened this issue on Jan 17, 2013 · 4 posts


parrotdolphin posted Thu, 17 January 2013 at 9:30 PM

I am trying to set a displacement amount and add a Spots node to the displacement. My script works to connect the Spots node to the displacement but I am not sure how to set the displacement amount or the Base_Color on the Spots node, or to tell it whether the Noise_Type is Improved or Original on the Spots node.

Does someone know? I would be grateful.

Thanks,
Janet

Here is the script:

import poser

def addDISP(mat):
    scene = poser.Scene()
    tree = mat.ShaderTree()
    root = tree.Node(0)

    if (root.Type() != poser.kNodeTypeCodePOSERSURFACE):
        print "Select a material first"
        return
        
    displacein = root.InputByInternalName("Displacement")
    
    dispin = displacein.InNode()

    #SetDisplacment(0.06)         #trying to set the amount of displacement
    furry = tree.CreateNode(poser.kNodeTypeCodeSPOTS)
    #furry.Input(0).Set???(0,0,0) #trying to set the Base_Color on Spots node to black
    furry.Input(2).SetFloat(0.01)
    furry.Input(3).SetFloat(0.5)
    furry.Input(4).SetFloat(0.5)
    #furry,Input(6).Set???(1)     #trying to set Noise_Type to Improved  
    furry.ConnectToInput(displacein)
    furry.SetLocation(400, 400)
    
    tree.UpdatePreview()

mat = poser.Scene().CurrentMaterial()    

addDISP(mat)


parrotdolphin posted Thu, 17 January 2013 at 10:18 PM

I think I got it figured out now. Here's the working script in case anyone is interested. It's to make a material furry.

 

import poser

def addDISP(mat):
    scene = poser.Scene()
    tree = mat.ShaderTree()
    root = tree.Node(0)

    if (root.Type() != poser.kNodeTypeCodePOSERSURFACE):
        print "Select a material first"
        return
        
    displacein = root.InputByInternalName("Displacement")
    displacein.SetFloat(0.7)       #sets the amount of displacement
    dispin = displacein.InNode()

    furry = tree.CreateNode(poser.kNodeTypeCodeSPOTS)
    furry.Input(0).SetColor(0,0,0) #sets the Base_Color on Spots node to black
    furry.Input(2).SetFloat(0.01)  #sets spot size
    furry.Input(3).SetFloat(0.5)
    furry.Input(4).SetFloat(0.5)
    furry.Input(6).SetFloat(2)     #sets Noise_Type to Improved  
    furry.ConnectToInput(displacein)
    furry.SetLocation(400, 400)
    
    tree.UpdatePreview()

mat = poser.Scene().CurrentMaterial()    

addDISP(mat)


markschum posted Thu, 17 January 2013 at 11:21 PM

:thumbupboth:


pitklad posted Wed, 23 January 2013 at 2:01 AM

Cool! I should give this a chance, thanks!


My FreeStuff