The second "call command" cannot be executed
-
Hello, I am always indebted to you.
When rendering is finished, I want to perform rendering again.
However, I am in trouble because the second command is not executed.
I want you to tell me. Please.import c4d from c4d import gui import datetime import time import threading PLUGIN_ID = 1058983 renderQ = 2 rdCheck = 0 class MainDialog(c4d.gui.GeDialog): def CreateLayout(self): self.SetTitle('Main Dialog') self.AddButton(1000, 0, name="RenderStart") self.AddButton(1001, 0, name="stop") return True def Command(self, Id, bc): global renderQ global rdCheck thread_rendercheck = threading.Thread(target=RenderCheck) if Id == 1000: RenderSetting() print('start Render') c4d.CallCommand(12099) thread_rendercheck.start() elif Id == 1001: renderQ = 0 rdCheck = 0 print('stop') def RenderSetting(): now = datetime.datetime.now() doc = c4d.documents.GetActiveDocument() renderData = doc.GetActiveRenderData() filename = 'path/test_'+str(now.microsecond)+'.png' renderData[c4d.RDATA_PATH] = filename renderData = doc.GetActiveRenderData().GetData() print(renderData[c4d.RDATA_PATH]) def RenderCheck(): global renderQ global rdCheck rdCheck = 1 while renderQ > 0: rdCheck = c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING) print("...now rendering") time.sleep(1) if rdCheck == 0: print('end') renderQ -= 1 print('render more… '+str(renderQ)) if renderQ > 0: RenderSetting() c4d.CallCommand(12099) print('start Render') return True class MainDialogCommand(c4d.plugins.CommandData): dialog = None def Execute(self, doc): if self.dialog is None: self.dialog = MainDialog() # Opens the dialog return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=400, defaulth=32) def RestoreLayout(self, sec_ref): if self.dialog is None: self.dialog = MainDialog() # Restores the layout return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref) # main if __name__ == "__main__": # Registers the plugin c4d.plugins.RegisterCommandPlugin(id=PLUGIN_ID, str="Py-RenderShread_test_kt Dialog", info=0, help="RenderTest GUI", dat=MainDialogCommand(), icon=None)
-
Hi,
What you are trying to do is not clear. You want to queue several renders?
If you want to be notified about the render progress you should use RenderDocument where you can define callback that will be called during the render.CallCommand must be used inside the mainThread otherwise it will not work. See GeIsMainThread for more information and this page for more information about threading inside cinema 4D
Cheers,
Manuel -
Thank you for your comment!
Yes. I want to queue several renders.I also want to operate the screen while rendering.
CallCommand must be used inside the mainThread otherwise it will not work.
Is that so. thank you.I have another question.
Is there an SDK to perform the rendering?I want to perform rendering while looking at the rendering result like [Render to Picture Viewer].
-
Hi,
That depend if you want to see the render while it is rendering or just the result. Using the example provided with RenderDocument you can call ShowBitmap once the render is finished.
But that is what the render queue is offering. (Except it will display the result in a small size preview) You can also use the render queue to push renders and still have a look at them.
If you want to display the result of the render while it's running, you will need to create your own GeDialog with a UserArea that will display the BMP. The BMP should be a global variable.
Cheers,
Manuel -
thank you for your reply.
If possible, I wanted to see the rendering results during rendering.
>If you want to display the result of the render while it's running, you will need to create your own GeDialog with a UserArea that will display the BMP. The BMP should be a global variable.
I wanna try!thank you!
-
Hello @mari,
without any further activity before Wednesday, the 16.03.2022, we will consider this topic as solved and remove the "unsolved" state from this topic.
Thank you for your understanding,
Ferdinand