THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/01/2011 at 17:49, xxxxxxxx wrote:
I want to add keyframe selections to certain properties of an object, for the sake of argument the ID_BASEOBJECT_REL_POSITION property.
The method wants a DescID type for the 1st argument and 0 or 1 for the second argument.
Unfortunately I have no idea how to get the DescID for the ID_BASEOBJECT_REL_POSITION property.
I can do it with an empty DESCID like this :
id = c4d.DescID()
I know it works because subsequently hitting the set key button doesn't generate any keyframes but I don't know how to read a specific property into the DescID.
Can anyone provide an example ?
On 29/01/2011 at 06:16, xxxxxxxx wrote:
Well I managed to get it to work with User Data, without really understanding why, by copying and altering a chunk of code I found:
id = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0),c4d.DescLevel(1))
But I still can't work out how to do it for the default properties, such as ID_BASEOBJECT_REL_POSITION, I just don't know the syntax.
On 29/01/2011 at 07:28, xxxxxxxx wrote:
OK, seems I found the syntax which works for every parameter apart from the coordinates :
id = c4d.DescID(c4d.ID_BASEOBJECT_VISIBILITY_EDITOR)
But it won't work for any of the coordinates, be they position, rotation, scale, rel or frozen.
Is this a bug ? or something special I have to do for these parameters ?
I thought this would work but no result :
id = c4d.DescID(c4d.ID_BASEOBJECT_REL_POSITION)
For anyone who's interested, my code for setting keyframe selections on userdata container some un-needed stuff, this is sufficient :
id = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(1))
On 30/01/2011 at 10:23, xxxxxxxx wrote:
In case it isn't clear what I'm trying to do :
My code should do the same as highlighting the object's parameter in the attribute manager, right clicking for menu and choosing Animation > Add Keyframe Selection. This makes the parameter turn orange and now when the 'set key' button is pressed with the object selected, only these highlighted parameters are keyframed.
This is useful to avoid generating unnecessesary keyframes on tracks you don't want to key, for example no point generating scale keys on a character's foot controller. It's also useful to make sure that user data or particular parameters are keyed along with position, rotation etc.
According to the python documents, you can do this in code by using the BaseList2D.SetKeyframeSelection() method.
The first argument you supply is the DescID of the parameter whose KeyframeSelection state you want to change and the second argument you supply is if it is in the Keyframe selection or not, using 0 for 'is not' and 1 for 'is'.
So the code :
sets the object's 'Visibile in editor' parameter as part of the KeyframeSelection
but when I try to do the same for the object's position parameter :
it doesn't work, the writing doesn't turn orange and position is not keyed when the 'set key' button is pressed. The same happens with any parameter in the 'Coord.' tab.
So either I need to use different syntax for these parameters, or there is a bug in this method.
Hope that explains it better.
Another user noted that it isn't working in C++ either, here's his code:
BaseObject *myObject = doc->GetFirstObject();
myObject->SetKeyframeSelection(ID_BASEOBJECT_VISIBILITY_EDIT OR,1); // This works fine
myObject->SetKeyframeSelection(#ID_BASEOBJECT_REL_POSITION,1 ); // This DOES NOT work!!
On 30/01/2011 at 18:27, xxxxxxxx wrote:
please try the following lines:
rel_pos=c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION, c4d.DA_VECTOR, c4d.Obase)
id = c4d.DescID(rel_pos, c4d.DescLevel(c4d.VECTOR_X, c4d.DA_REAL, c4d.DA_VECTOR))
id = c4d.DescID(rel_pos, c4d.DescLevel(c4d.VECTOR_Y, c4d.DA_REAL, c4d.DA_VECTOR))
id = c4d.DescID(rel_pos, c4d.DescLevel(c4d.VECTOR_Z, c4d.DA_REAL, c4d.DA_VECTOR))
The selection must be assigned to each subchannel. The TranslateDescID function in C++ helps here to get the corresponding DescID, but this is currently not wrapped in Python. Anyway, the lines I posted should help you here.
On 30/01/2011 at 19:16, xxxxxxxx wrote:
I know this is the Python forum.
But do you happen to know the C++ equivalent to this code Sebastian?
I tried to convert it myself. But I'm still too new at the C++ API to get it converted correctly.
On 31/01/2011 at 13:46, xxxxxxxx wrote:
Many thanks, Sebastian !