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