Type Error using Init()
-
On 15/12/2015 at 07:24, xxxxxxxx wrote:
Hi!
I'm completely new to plugin programming and stumble my way through the doc and examples, but I'm stuck on an error. Maybe you guys can help me out.
I'm trying to initalize description attributes from a .res file with the Init()/InitAttr() functions.
The example from the doc is:import c4d def Init(self, node) : #please note, the desc element has to be a constant (id of your container element) self.InitAttr(host=node, type=float, desc=[c4d.PY_TUBEOBJECT_RAD]) self.InitAttr(host=node, type=float, desc=[c4d.PY_TUBEOBJECT_IRADX]) node[c4d.PY_TUBEOBJECT_RAD]= 200.0 node[c4d.PY_TUBEOBJECT_IRADX] = 50.0
When I follow the syntax I get the error: _ TypeError: Required argument 'id' (pos 3) not found_
I assume, that the example is wrong and the 'desc' argument should be 'id', but I might be wrong about that.
When I change it to 'id' the attributes are set correctly, but I get the error: TypeError: Init expected bool, not None
_
_
This might be unrelated, but the Init() function also seems to be called every time I edit an attribute in the description. Is it supposed to do that? -
On 15/12/2015 at 08:31, xxxxxxxx wrote:
Hi and welcome to the Plugin Cafe!
I'm sorry the example for NodeData.InitAttr() is wrong.
desc parameter in the example is in fact callled id as you noticed. This will be fixed.You can find the Py-RoundedTube ObjectData example (this one run and is fixed) in the example s folder of the Python SDK documentation archive.
Originally posted by xxxxxxxx
This might be unrelated, but the Init() function also seems to be called every time I edit an attribute in the description. Is it supposed to do that?
Yes this is normal. I won't go into details but this is because of the undo mechanism of Cinema.
-
On 15/12/2015 at 08:54, xxxxxxxx wrote:
Thank you for the quick response!
I'm definitely going to check out the examples!
Thanks again.