Text updated with Python in CLR doesn't render
On 02/11/2017 at 07:35, xxxxxxxx wrote:
I'm trying to update some values in a scene (text, texture from files and colours) before rendering using the Python SDK.
Updating the textures and colours works fine, but when I update the text it no longer renders.
I'm using a Python plugin to listen for the command line arguments message (ultimately I'll use those values for customising) and update the scene, before rendering it out.
I'm invoking the command line renderer with the -nogui and -debug flags:
/opt/maxon/cinema4d/19.024/bin/Commandline -nogui -debug
Here's how I'm updating the colour:
extrude_object = doc.SearchObject("Extrude") extrude_object[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(1, 0, 0.6)
This works fine; when the scene is rendered out the colour change is as I expect.
Here's how I'm updating the text:
text_object = doc.SearchObject("Text") text_object[c4d.PRIM_TEXT_TEXT] = "Hello"
This works in the Python console in Cinema 4D, and in the plugin it seems fine. Querying back the value and printing it out shows what I've just set. However, when the scene is rendered out, the text is completely missing.
The template is using a spline for text. When using MoText I get the same output (ie, no text at all) but I also get some errors printed during rendering:
CRITICAL: NullptrError [text_object.cpp(885)] [objectbase1.hxx(370)] CRITICAL: NullptrError [text_object.cpp(885)] [objectbase1.hxx(370)] CRITICAL: NullptrError [text_object.cpp(617)] [objectbase1.hxx(370)]
Have any of you experienced this issue before? Have you managed to successfully update text values using Python and the -nogui flag?
Side note: In my real scene I'm using UserData for the values, wired up with XPresso to make the text and colours update. I get the exact same behaviour with that as I'm describing here, but to set the values I use something like:
custom_data[c4d.ID_USERDATA, 1] = c4d.Vector(1, 0, 0.6) custom_data[c4d.ID_USERDATA, 2] = "Hello"
I've made a very simple scene to demonstrate the issue, you can download it here: http://dom.evilstreak.co.uk/simple-text-scene.c4d
It looks like this
Here's the script I'm using in full to test this:
import c4d import sys def PluginMessage(id, data) : if id==c4d.C4DPL_COMMANDLINEARGS: return render_pngs(sys.argv) return False def render_pngs(command_line_args) : path = "/home/ubuntu/simple-text-scene.c4d" c4d.documents.LoadFile(path) doc = c4d.documents.GetActiveDocument() # customise it text_object = doc.SearchObject("Text") text_object[c4d.PRIM_TEXT_TEXT] = str("Hello") extrude_object = doc.SearchObject("Extrude") extrude_object[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(1, 0, 0.6) # render it renderData = doc.GetActiveRenderData().GetData() xres = int(renderData[c4d.RDATA_XRES]) yres = int(renderData[c4d.RDATA_YRES]) bmp = c4d.bitmaps.BaseBitmap() bmp.Init(x=xres, y=yres, depth=24) renderData[c4d.RDATA_GLOBALSAVE] = True renderData[c4d.RDATA_SAVEIMAGE] = True renderData[c4d.RDATA_FORMAT] = c4d.FILTER_PNG renderData[c4d.RDATA_FRAMESEQUENCE] = c4d.RDATA_FRAMESEQUENCE_MANUAL renderData[c4d.RDATA_FRAMEFROM] = c4d.BaseTime(0.5) renderData[c4d.RDATA_FRAMETO] = c4d.BaseTime(0.5) path = "/home/ubuntu/frames/frame" renderData[c4d.RDATA_PATH] = path renderData.SetFilename(c4d.RDATA_PATH, path) res = c4d.documents.RenderDocument(doc, renderData, bmp, c4d.RENDERFLAGS_EXTERNAL | c4d.RENDERFLAGS_NODOCUMENTCLONE) return True
On 03/11/2017 at 09:12, xxxxxxxx wrote:
welcome to Plugin Café forums
We are looking into this, but it might take a few days. I'll get back to you as soon as I have any information.
On 03/11/2017 at 09:32, xxxxxxxx wrote:
Hi Andreas, thanks for the update! I've also found what I think may be a problem with the Python libraries bundled with the R19 command line renderer client – should I start a new thread for that?
On 03/11/2017 at 09:34, xxxxxxxx wrote:
please hold on for moment. We'll get in contact with you.
On 03/11/2017 at 12:06, xxxxxxxx wrote:
Can sound stupid but in your plugin there is no c4d.EventAdd(). And since c4d console automaticly add event for you it's why it's work in the console.
You may need to add event before to render. Since lunching a render mean a copy of the scene internally, I don't know if data set in the scene but not being pushed by an Event are computed in this copy of the scene.
But I could be wrong I'm not as much experienced as c4d command line plugin
On 03/11/2017 at 15:06, xxxxxxxx wrote:
Hi gr4ph0s, thanks for the suggestion – and it doesn't sound stupid at all!
While working on the issue I saw some other scripts that used c4d.EventAdd(), and have tried both with and without it, but sadly it didn't make any difference. Your line of thinking matches mine – that somehow the new data isn't being prepared properly for the render, and there's perhaps another command I need to run. Andreas said he's looking into it for me now so hopefully we'll find out :)