Forum

  • Index
  •  » Scripting
  •  » How to get a Dynamic Attribute Value from an Object selected

#1 2017-12-02 00:31:30

xiaoshibo
Member

How to get a Dynamic Attribute Value from an Object selected

Hi Ben,

Hope you are doing well on your end.

I have a question about how to Check if the dynamic attribute exists ('Glass' for example), then how to get its value in Python.

Thank you in advance,

Shibo

example:

> Transform
> Node
> Dynamic Attributes
   IOR 1.35 ---------------------------------------------------------o>
Glass 1.00 ---------------------------------------------------------o>
Spec1 0.08 ---------------------------------------------------------o>
>Geometry




I finally find out a way to get the value, but I got the error sometimes:



d = guerilla.Document()
sel = d.selection()
node = sel[0]

# The line below produces the error (RuntimeError: Unable to bind lua class rgopvalue), I have no idea what is rgovalue.
result = guerilla.SceneGraphNode.getrenderattributes(node, True)

try:

    attributes = result['attributes']
    for name, value in attributes.iteritems():
        if name == 'variable.Glass':
            print (name, value)
except:
            print 'error'

Last edited by xiaoshibo (2017-12-02 02:37:09)


Lighting Artist

Offline

 

#2 2017-12-02 13:49:55

Ben
Guerilla dev, the guy to hug

Re: How to get a Dynamic Attribute Value from an Object selected

Hi Shibo,

This is a bug. A Lua class (rgopvalue) is not properly bound in Python, and when you get the node attributes, converting the Lua value into Python will cause this exception. I'll fix that soon, sorry.

Ben


Benjamin 'Ben' Legros
Guerilla developer
http://www.guerillarender.com

Offline

 
  • Index
  •  » Scripting
  •  » How to get a Dynamic Attribute Value from an Object selected

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB