Underlying of "doc" and "op" ?
-
I'm confused about
doc
andc4d.documents.GetActiveDocuments()
in aPython Tag
.Here is the code in a
Python Tag
:import c4d #Welcome to the world of Python def main(): aDoc = c4d.documents.GetActiveDocument() print("Active Doc:\n{}\ntime:{}".format(aDoc, aDoc.GetTime().Get())) print(" ") print("doc:\n{}\ntime:{}".format(doc, doc.GetTime().Get())) print(" ")
If I scroll playhead in the scene, both
aDoc
anddoc
with their time is same.
If I start an image sequence render,
aDoc
anddoc
report the same object,
but "time" ofaDoc
still represents the playhead in the scene,
and "time" ofdoc
represents the current render frame's time.Is there some difference between the two of them?
And Is there any function that can produce the same result of
op
in aPython Tag
? -
I guess the "op" can be obtained from a tag via GetObject()
-
Hello,
a Python Tag is part of the scene.
When you render a scene in the Picture Viewer, Cinema 4D will create a copy of that scene. That copy is then rendered. The copy of the scene includes a copy of your Python Tag.
GetActiveDocument()
returns the active document. The active document is the document you are currently looking at in the viewport. So this document is not the same document as the document you are currently rendering.For example: you can start rendering a document in the Picture Viewer and then close the currently open document while the rendering is still going on. That is why you should never reference the active document in any code that might be executed in the rendering pipeline.
doc
is the document that currently owns the Python Tag. When you are rendering in the Picture Viewer,doc
is the document that is currently rendered. Not the active document.The
op
variable references the tag itself. Again, when you are rendering, the scene (including the tag) is copied.best wishes,
Sebastian -
Hi, @C4DS and @s_bach, thank you for replies!
@C4DS, do you mean to write
op.GetObject()
in aPython Tag
? That will produce the object thatPython Tag
attached.
Or do you mean writing outside ofPython Tag
? If I can write this script outside thisPythion Tag
, I should know which is thePython Tag
already, in this case, I don't need to useop
to getPython Tag
.
I'm a little confused about your meaning in the post.@s_bach, after reading your post, I understand that
Active Document
andScene being Rendering
is different. And I should never useActiveDocument
within arender pipeline
.
Here I still have one more question:
There is no other way in aPython Tag
to produce the same result asdoc
andop
; they are very special variables. Am I correct? -
Hello,
in a Python tag,
op
points to the tag itself. Right now I don't see any other way to get this reference.doc
references to the document that owns the tag. So it is the same as op.GetDocument().best wishes,
Sebastian -
@s_bach, thank you very much! Now I see the whole picture!
-
@eziopan said in Underlying of "doc" and "op" ?:
@C4DS, do you mean to write
op.GetObject()
in aPython Tag
? That will produce the object thatPython Tag
attached.
Or do you mean writing outside ofPython Tag
? If I can write this script outside thisPythion Tag
, I should know which is thePython Tag
already, in this case, I don't need to useop
to getPython Tag
.
I'm a little confused about your meaning in the post.Sorry, was away for a few days and couldn't respond earlier.
What I assumed you wanted to achieve was a way to obtain the "op" as if creating a regular script.
There the "op" is the current active object.
I misinterpreted your question, and didn't see your reference to the Python tag. Hence, I wrongly assumed you wanted to access the "op" as if from a user script, thus the active object, and therefore I mentioned to use "op.GetObject()" to obtain the object the tag was attached to.
I made too many wrongly assumptions. Sorry about that. -
@c4ds, don’t worry! Every steps (even the off-road one) make some progress, right? I appreciate the way you focusing on the problem solving, which I believe is also the wonderful thing of this forum: we do our best to solving the problem itself, discussing about the better/more accurate answers rather than “who is right, who is wrong”. Last but not least, thank you for taking time to reply!