1
$\begingroup$

I'm working on adaptation some addon from 2.79 to 2.8x. It uses property groups to fill other objects with recurring attributes.

TestProps:
my_float_prop: bpy.props.FloatProperty(default=3.1415926)

MyCustomNode:
my_float_prop: TestProps.my_float_prop

With 2.79 using = assignment addon works fine. But 2.8x with pep-0526 I'm getting

AttributeError: type object 'TestProps' has no attribute 'my_float_prop'

I had created github repo demonstrates my problem with same project structure.

$\endgroup$
3
  • $\begingroup$ Hi. Any relevant code (like a basic working example that still demonstrates the issue) should be in the question body itself. Thanks. $\endgroup$ Commented Jul 1, 2020 at 12:20
  • 1
    $\begingroup$ It is now defined as an annotation. Try something like TestProp.__annotations__["my_float_prop"] Consider too using math.pi. $\endgroup$
    – batFINGER
    Commented Jul 1, 2020 at 12:28
  • $\begingroup$ Thanks, batFINGER. That wotks! $\endgroup$
    – RUben
    Commented Jul 1, 2020 at 12:33

1 Answer 1

2
$\begingroup$

Using annotations rather than class properties

It is now defined as an annotation. They are added to a key value dictionary __annotations__ on the class on which they are defined. Try something like

TestProp.__annotations__["my_float_prop"]

There is a generic Namespace class where can

from argparse import Namespace
props = Namespace(**TestProp.__annotations__)

and then access them via

props.test_float_prop 

Consider too using math.pi.

$\endgroup$
1
  • $\begingroup$ Another thanks for Namespace solution $\endgroup$
    – RUben
    Commented Jul 2, 2020 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .