On 02/05/2014 at 00:38, xxxxxxxx wrote:
Here's my first post here. Seems there's a great community here!
I'm currently working on an OSC plugin for C4D which allows you to use c4d as a timelining tool for creative coding purposes. So far it works great, but i'm a little slow at picking up the Python API so far....
Enumerate all User Data parameters for a c4d.BaseObject, and for each get the name and the current value.
I have test parameters:
* brightness (real)
* resolution (long)
* name with spaces (%)
* subgroup (group)
* testSubGroupMember (%)
And if I do:
[((2, 19, 0), <c4d.BaseContainer object at 0x118e17bc8>), ((1, 15, 0), <c4d.BaseContainer object at 0x118e0eae8>), ((4, 19, 0), <c4d.BaseContainer object at 0x118f4e340>), ((5, 1, 0), <c4d.BaseContainer object at 0x118f4e308>), ((6, 19, 0), <c4d.BaseContainer object at 0x118f4e030>)]
so i'm able to get the name of each parameter by doing like:
userData = obj.GetUserDataContainer()
[returns] : brightness
then i get the name of the 0th parameter, great! so now all I need is the value...
To get each value, I can use
print obj[c4d.ID_USERDATA, index ]
and i can see the correct index from
[returns] ( 2 , 19, 0)
which is a DescID, and is useful, because it means I can do
print obj[c4d.ID_USERDATA, 2 ]
[returns] : 0.083
Which is the correct value.
So far, wonderful!
So now I have to get that index of 2 out of the DescID, so I would do something like:
[returns] <c4d.DescLevel object at 0x117c241f8>
ok, so that wasn't what I wanted, we get a DescLevel instead of a DescId,
so let's see if we can get the 2 out of that DescLevel....
print obj[c4d.ID_USERDATA, userData.id
ok so how do I get the 2 out? I can't see any other accessors which are useful here
currently the only option i can see is
idString = obj[c4d.ID_USERDATA, userData.__str__()
and then performing string operations to get the 2 out of "(2, 19, 0)"
but that seems crazy. which is where the question come in :).
how to get the 2 out of the DescID?
To note, I'm doing this within the context for an plugins.ObjectData and looking at the child objects