Rendering in Python: LineSets & LineStyles

#1

I’m trying to render a scene with a python script using custom Linesets, but it doesn’t render the proper LineStyle settings.

Running the script below does seem to change the settings. I can check the values in the UI window and they do change, however, the rendered images do not reflect the settings.
If I render the scene by pressing the “Render” button in the UI, it renders with the correct LineStyle settings.
Is there a render setting I’m missing?

Also, how do I select and modify different LineSets using python? I want to be able to select one Lineset and modify it’s settings, then select another and modify it’s settings.

bpy.context.scene.render.layers["RenderLayer"].use_freestyle = True
    
#change to script mode
rl = bpy.context.scene.render.layers.active
rl.freestyle_settings.mode = 'SCRIPT'
freestyle = rl.freestyle_settings
lineset = freestyle.linesets.active
lineStyle = lineset.linestyle
lineStyle.thickness = 1.53
lineStyle.color = (0, 255, 255)
0 Likes

#2

I found the issue. I needed to remove this line:

rl.freestyle_settings.mode = 'SCRIPT'

I think by setting the Freestyle Settings mode to SCRIPT, it tries to configure the active Freestyle Line Style settings from a pre-created python file. Which is why my python generated renders didn’t render with the correct settings (the settings set through my script and are visible in the UI).

0 Likes