Convert Integer values to string in switch node.

   1789   2   1
User Avatar
Member
10 posts
Joined: April 2019
Offline
Hello Guys,

I am trying to use a Wedge node attribute in Tops to push the values inside a switch node in sops. But instead of using an Integer, I want the Attribute string type in Tops to control the values in the switch node.

For example in my tops I have a Wedge node with a attribute name: balls , the type is a String and the string values are: 1. Red, 2. Blue, 3. Purple.

How do I then connect this to a switch node and allow it to connect to the right integer value on the switch now.

I have attached a quick test scene demonstration what i am trying to do.

Attachments:
tempscene.hip (295.4 KB)

User Avatar
Member
9417 posts
Joined: July 2007
Offline
you can do it for example with python expression like this
colors = [input.name() for input in hou.pwd().inputs()]
color = pdg.workItem().attribValue("balls")
return colors.index(color)
which would switch to the input whose name is the same as balls attribute value

Attachments:
tempscene_fix.hip (317.1 KB)

Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
10 posts
Joined: April 2019
Offline
Thank for that. It works !!
  • Quick Links