Vector3 Property

Discussions concerning programming of SOFTIMAGE©
User avatar
TwinSnakes007
Posts: 316
Joined: 06 Jun 2011, 14:00

Vector3 Property

Post by TwinSnakes007 » 25 Jan 2013, 01:24

Does anyone know how to read a Vector3 property? No matter what I try, it always returns "None".

This Python snippet creates a Vector_Switch node which has two Vector3 properties. No matter what I set them too, or how I try to access their value, I only get "None".

Code: Select all

from sipyutils import *

app = Application
Application.CreateShaderFromProgID("Softimage.sib_vector_switch.1.0", "Sources.Materials.DefaultLib.Scene_Material", "Vector_Switch")
oMatLib = app.ActiveProject.ActiveScene.MaterialLibraries

for oLib in oMatLib :
	for oMaterial in oLib.Items :
		oShaders = oMaterial.GetAllShaders()
		for oShader in oShaders:
			for oParam in oShader.Parameters:
				log(oParam.Name + ": " + str(oParam.Value))

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 00:41

Re: Vector3 Property

Post by EricTRocks » 25 Jan 2013, 02:05

the property probably breaks the down into the individual x,y,z values and the none value usually indicates that it is returning a collection of items that you need to get the values from directly.
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken

User avatar
TwinSnakes007
Posts: 316
Joined: 06 Jun 2011, 14:00

Re: Vector3 Property

Post by TwinSnakes007 » 25 Jan 2013, 02:14

EricTRocks wrote:the property probably breaks the down into the individual x,y,z values and the none value usually indicates that it is returning a collection of items that you need to get the values from directly.
I've tried that, nothing works. I tried passing it to XSIMath.CreateVector3, still nothing.

Tried accessing the X, Y, Z properties directly, that didnt work.

The only thing I get is "None" when I try to read it. I must be missing something.

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 13:31
Skype: csaezmargotta
Location: Sydney, Australia

Re: Vector3 Property

Post by csaez » 25 Jan 2013, 02:15

Hey TwinSnakes007,
There are some parameter types with sub parameters, in such cases you must iterate in the sub parameters in order to get the values :)

Code: Select all

from sipyutils import si, log

si().CreateShaderFromProgID("Softimage.sib_vector_switch.1.0", "Sources.Materials.DefaultLib.Scene_Material", "Vector_Switch")
oMatLib = si().ActiveProject.ActiveScene.MaterialLibraries

for oLib in oMatLib :
   for oMaterial in oLib.Items :
      oShaders = oMaterial.GetAllShaders()
      for oShader in oShaders:
         for oParam in oShader.Parameters:
            oValue = oParam.Value
            if oParam.Parameters.Count:
                oValue = map(lambda x: x.Value, oParam.Parameters)
            log("{0}: {1}".format(oParam.Name, oValue))

User avatar
TwinSnakes007
Posts: 316
Joined: 06 Jun 2011, 14:00

Re: Vector3 Property

Post by TwinSnakes007 » 25 Jan 2013, 02:24

wow...okay... :D

Thank you soo much! That really helped me alot. I was stumped on that for weeks.

-TS-