On 15/05/2017 at 08:50, xxxxxxxx wrote:
I'm new to python development into C4D.
I am developing some pipeline tools that 'communicate' with different 3d apps (Maya, Houdini, C4D, etc.). Basically, it's an external application (python, PySide), and it does communicate with 3d apps to ask them to perform some commands. (IE: Open scene/document, Import specific file, exports file, save document etc.)
I am using OSC modules to communicate from my PySide apps to C4D.
I am having a problem when trying to export alembic files using R18 (R18.041), while it does work fine with R17.
I am suspecting that, when using OSC modules to perform my action, it does uses a different thread then C4D's main thread? (Is it possible, how can I test?) And with that example, it seems I cant export alembic file using different thread?
Basically, from withing C4D:
print documents.SaveDocument(doc, 'C: ext.abc', c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, 1028082)
return true, and it does export and alembic file.
While using OSC, C4D does listen to a specific commands (IE: Export ABC), I will execute the same command:
Will also return True, but doesn't export anything.
Is there a way I can query the current thread that C4D uses? Can I force my execution tu uses main C4D thread?
Does someone out there uses an other way than OSC to communicate with C4D and execute python commands?
Does it work exporting alembic files?
again... same codes work very well in R17, but doesnt in R18.
On 15/05/2017 at 09:25, xxxxxxxx wrote:
To know if you are the main thread take a look at https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.threading/index.html#c4d.threading.GeIsMainThread
But for you issue (exporting to abc) I suggest you to read this exemple.
I don't know about the R17 so you have to wait official answer but I know in R18.32(if I'm right) there is a bug into the alembic export, so make sure to have an updated version of c4d.
About executeOnMainThread there is no proper solution for it. But you can easily register a MessageData plugin which has an CoreMessage function. Overide it and call it with a custom ID from your plugin.
For more informations https://plugincafe.maxon.net/topic/9847/13260_christmas-competition-2016--executeinmainthread&PID=52613#52613
And basicly SaveDocument can only save a .c4d file so I guess it's why it's fail (but I can be wrong for that ^^')
On 16/05/2017 at 09:18, xxxxxxxx wrote:
gr4ph0s once again made most of my work. Thanks!
Just one minor correction, like shown in the linked ExportAlembic example SaveDocument() is not limited to .c4d files, but can be used to export scenes to different formats as well.
@Jonathan: I'm terribly sorry, I didn't get back to you on the other thread.
I used your code from the other thread to do some tests here. I can reproduce the issue in R18. After some further investigation I can tell the problem is already known and will be fixed in a future release.
So long the MessageData hint in third paragraph of gr4ph0s answer should definitely be a good workaround for you.