1
$\begingroup$

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

option 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?

$\endgroup$
  • $\begingroup$ Please copy-paste the script into your question in text. $\endgroup$ – Antti Haapala Apr 8 '16 at 18:07
1
$\begingroup$

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.