Isotropix Forums

Python shading_variables attribute access

Clarisse Scripting related topics

Python shading_variables attribute access

Unread postby stheroux » Tue Aug 07, 2018 10:14 pm

Hello guys,

I'm trying to access shading variables attribute value in python, something like:

python code

my_shading_variables = my_object.get_attribute("shading_variables").get_string()
#or
my_shading_variables = my_object.get_attribute("shading_variables").get_object()

but im not sure what type i'm expecting and none of them seem to work. Passing in a array does not seem to work either.

Thanks
Sylvain
stheroux
 
Posts: 59
Joined: Thu Jan 15, 2015 10:23 pm

Re: Python shading_variables attribute access

Unread postby bvaldes » Wed Aug 08, 2018 9:51 am

Hello,

In python you have a wonderful function called dir() this function gives you the method that are accessible from the object given as argument. So if you try to print dir(my_attribute) that will give you all the function that you can use (like get_string(), get_double()...). That will help you in the future to find the right function to do what you want to.

To get the shading variable value of an attr (for example color) do like this:

python code

constant_color = ix.get_item("project://constant_color")
color_attr = constant_color.get_attribute("color")
if color_attr.is_shading_variable_activated(): # Check if the shading variable is activated on this attribute
print color_attr.get_bound_shading_variable() # Get the content of the shading variable


If you need more information, feel free to ask.

Regards
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 265
Joined: Mon Sep 26, 2016 11:44 am

Re: Python shading_variables attribute access

Unread postby stheroux » Wed Aug 08, 2018 1:57 pm

Hi Benoit,

Sorry might not have been clear, but I'm not looking for a the value of shading variable bounded to an attribute. I'm trying to get the value of attribute named 'shading_variables' (on a GeometryAbMesh in this case).

get_bound_shading_variable() seems to return nothing in this case.

Thanks for the dir() tip, it is very useful.
Sylvain
stheroux
 
Posts: 59
Joined: Thu Jan 15, 2015 10:23 pm

Re: Python shading_variables attribute access

Unread postby stheroux » Wed Aug 08, 2018 2:11 pm

So going through all the get() methods, get_raw_string() seems to work.
Il'l go with that.
Thanks
Sylvain
stheroux
 
Posts: 59
Joined: Thu Jan 15, 2015 10:23 pm

Re: Python shading_variables attribute access

Unread postby bvaldes » Wed Aug 08, 2018 5:44 pm

Hi,

Sorry for the misunderstanding, happy you found the answer by your own.

Cheers
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 265
Joined: Mon Sep 26, 2016 11:44 am


Return to Scripting