Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
On 15/12/2017 at 13:17, xxxxxxxx wrote:
Hi!
I'm looking to write a simple script that goes through each frame and saves some data (position and rotation coordinates) from the selected object. However the documentation lists only methods, no properties and I can't figure out how to access the data.
Dragging in the name of the coordinate field to the Python editor places something like this in the code: [c4d.ID_BASEOBJECT_POSITION,c4d.VECTOR_X], which is a list of 2 integers that don't seem to correlate to the value of the given coordinate.
Help please, thank you, zoliking
On 17/12/2017 at 11:37, xxxxxxxx wrote:
So after failing to find a tutorial I decided to find some example scripts and try to get somewhere from there. I managed to find the method doc.GetFirstObject(), which allowed access to the data I need. However I ran into a new problem: the instance it returns seems to contain the information about the object on the frame I start the script on, not the frame that the application is on during the call. Any ideas?
def goToFrame(frameNumber) : fps = doc[c4d.DOCUMENT_FPS] time = c4d.BaseTime(frameNumber, fps) doc.SetTime(time) c4d.EventAdd()
def main() : data = [] for i in range(0,46) : goToFrame(i) selectedObject = doc.GetFirstObject() pos = selectedObject.GetAbsPos() rot = selectedObject.GetAbsRot() data.append(pos.x) data.append(pos.y) data.append(pos.z) data.append(rot.y) data.append(rot.x) data.append(rot.z)
On 18/12/2017 at 01:58, xxxxxxxx wrote:
Hello,
Objects in Cinema 4D store parameters. Such parameters are identified using a DescID object. A DescID object is made of various numbers and these numbers are typically defined using symbols. c4d.ID_BASEOBJECT_POSITION and c4d.VECTOR_X are such symbols. So you can use these symbols to access parameter values using GetParamter() :
descid = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_POSITION, 0, 0), c4d.DescLevel(c4d.VECTOR_X, 0, 0)) xCoordiante = op.GetParameter(descid, c4d.DESCFLAGS_GET_0)
But there are shorter ways of writing the same thing using the subscript operator:
xCoordiante = op[c4d.ID_BASEOBJECT_POSITION,c4d.VECTOR_X]
In the online documentation you find information on GetParameter() and DescID. You find various Python examples in the Python documentation download and on GitHub.
Setting the time of a document will NOT animate the document. To animate the document you explicitly do that. This can be done using ExecutePasses().
A similar topic was just discussed in this thread: "python plugin for every frame".
You also find additional information in the C++ documentation on these topics: BaseDocument Manual.
best wishes, Sebastian
On 18/12/2017 at 08:33, xxxxxxxx wrote:
ExecutePasses() worked, thank you for that and all the other great information too! You are a life saver!