Problem with shader nested parameters in XSI? Workarounds?

Date : Fri, 07 Apr 2006 15:45:00 -0700
To : xsi(at)Softimage.COM
From : Andy Jones <andy(at)thefront.com>
Subject : Problem with shader nested parameters in XSI? Workarounds?
# I think this python code demonstrates a problem with parameter updates in XSI 5.1.
# What seems to happen is that when a datasource is removed from a shader parameter,
# the nested parameters don't get recreated until after the script has finished running.
# This is a problem because in a lot of scripts, I might want to replace shader inputs
# with hard-coded values.


# Instructions: Run the script twice. Ideally, the value of the red parameter
# of the diffuse input on the scene material's phong should be logged twice. # Instead, the red parameter is inaccessible, even after the shader input is
# disconnected, until the script has finished.


def LogRed(colorParam):
   try:
       # Attempt to read a value from red component
       Application.LogMessage(colorParam.red.Value)

   except:
       Application.LogMessage("Failed to retrieve red parameter")

# Try to list the parameters (none get listed)
for p in colorParam.Parameters:
Application.LogMessage(p.FullName)


# Grab the diffuse input of the scene material
try:
Application.SelectObj("Sources.Materials.DefaultLib.Scene_Material", "", "")
scnMatPhongDiffuse = Application.Selection[0].surface.source.diffuse
except:
Application.NewScene("", "")
Application.SelectObj("Sources.Materials.DefaultLib.Scene_Material", "", "")
scnMatPhongDiffuse = Application.Selection[0].surface.source.diffuse


# Connect and disconnect a shader every other run of the code and try to log red value
if (scnMatPhongDiffuse.Source == None):
LogRed(scnMatPhongDiffuse)
Application.LogMessage("Connecting shader to diffuse")
scnMatPhongDiffuse.ConnectFromProgID("Softimage.txt2d-image-explicit.1")
else:
Application.LogMessage("Disconnecting shader from diffuse")
scnMatPhongDiffuse.Disconnect()
LogRed(scnMatPhongDiffuse)


---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.