# Try use option Freestyle in script for Blender

I'm about to write a script that allows to make "true" the options (Freestyle in Blender):

Here is the python script I 'm writing to try to use options Script python

import bpy

sceneR = bpy.context.scene

freestyle = sceneR.render.layers.active.freestyle_settings
linestyle = bpy.types.FreestyleLineSet
sceneR.render.use_freestyle = True
sceneR.svg_export.use_svg_export = True
freestyle.use_smoothness = True
freestyle.use_culling = True
linestyle.select_by_visibility = True
linestyle.select_by_edge_types = True
linestyle.visiblity = 'RANGE'
linestyle.select_silhouette = True


I found it in the window "info" Blender indicating each action done in Blender

my problem is that when I run the script it that nothing happens , and options (circled in red on the first picture) are always off or False .

Do I put the wrong way , is there a different way to activate this option in a script?

– Antti Haapala
Apr 8 '16 at 18:07

You are close, the use of bpy.types.FreestyleLineSet is wrong as this refers to the class definitions used elsewhere. The correct way to add a new lineset is freestyle.linesets.new('mylineset'), you also have a typo in linestyle.visiblity = 'RANGE'

A working version of your example is

import bpy

sceneR = bpy.context.scene
freestyle = sceneR.render.layers.active.freestyle_settings

linestyle = freestyle.linesets.new('mylineset')
sceneR.render.use_freestyle = True
sceneR.svg_export.use_svg_export = True
freestyle.use_smoothness = True
freestyle.use_culling = True
linestyle.select_by_visibility = True
linestyle.select_by_edge_types = True
linestyle.visibility = 'RANGE'
linestyle.select_silhouette = True

• But i dont find a other typo for passe the option visibility to RANGE and take True for Silhouette ??
– Sofiane Rahaoui
Apr 18 '16 at 18:44
• In your code you have linestyle.visiblity = 'RANGE' - with a missing i in visibility the silhouette setting should be right. Apr 18 '16 at 18:54