2
$\begingroup$

I have encountered a problem with Python scripting for Blender.

I have a script which recieves meshes via an external source, and adds them to the scene. A specific type of mesh is added to the second layer. If such a mesh is created, a second RenderLayer is created and Freestyle-Rendering is activated. So far, all of this works as I wish. But I want to add specific Freestyle-Brush-Color to each of this meshes, and so I want to create a Lineset with a linked LineStyle for each one.

Problem now: How can I create and manage the LineSets. I can create a LineSet for the active RenderLayer but without name, and the creation method does not return a handle to that LineSet. How do I cleanly and efficiently retrive the newly created LineSet so that I can add a LineStyle and other settings to it?

My RenderLayer-related code so far:

LineRenderLayer = None
    if not "PolyLineLayer" in bpy.context.scene.render.layers:
        bpy.context.scene.render.use_freestyle = True
        bpy.context.scene.layers = [True] * 2 + [False] * 18
        bpy.context.scene.render.layers["RenderLayer"].layers = \
            [True] + [False]*19
        bpy.ops.scene.freestyle_lineset_remove()
        LineRenderLayer = bpy.context.scene.render.layers.new("PolyLineLayer")
        LineRenderLayer.use_freestyle = True
        LineRenderLayer.layers = [False] + [True] + [False] * 18
    else:
        LineRenderLayer = bpy.context.scene.render.layers["PolyLineLayer"]


    bpy.context.scene.render.layers.active = LineRenderLayer

    bpy.ops.scene.freestyle_lineset_add()

The last line is the main problem. It does not take a name as parameter and does not return anything. But I need that created Lineset for further configuration.

I use Blender in version 2.70

Thank you for your help!

Greetings, Dragonseel

$\endgroup$
  • $\begingroup$ You can access the linesets data from bpy.context.scene.render.layers['PolyLineLayer'].freestyle_settings.linesets[] while I expected ....linesets.new() to work, it doesn't, so I'm not certain of a better way to create new LineSets. $\endgroup$ – sambler May 7 '14 at 3:00
  • $\begingroup$ So I just assume the new lineset will be added as the last entry in the lineset collection? Because I do not know anything about it. It gets a name like "LineSet X" but I don't know the number. Searching for it would be difficult. $\endgroup$ – Dragonseel May 7 '14 at 14:21
1
$\begingroup$

It is an API design bug that the collection of line sets does not have a .new() and .remove() method. I will address this problem as soon as possible, preferably in the next Blender 2.71 release.

$\endgroup$
  • $\begingroup$ Fixes were made in the Blender code repository and will be part of Blender 2.71. $\endgroup$ – T.K. May 11 '14 at 13:48

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.