1
$\begingroup$

I want to make a blender script, to export wireframes.

Honestly I dont have much knowledge on the python thing so I only copied some code from the window over the gui and filled it in a text document.

But on this Code i have troubles:

bpy.context.scene.select_edge_mark = True

this one is for activating the Edge Mark checkbox from the Freestyle Addon.

bpy.context.space_data.context = 'RENDER_LAYER'

and this one should only change from window render to window render layer, but if the edge mark thing would work i wont need these code.

So, what i am doing wrong, or better, what is causing this, because honestly i think i am doing a lot wrong :D

$\endgroup$
2
  • $\begingroup$ PS: Error from console: $\endgroup$
    – Luki Krew
    Commented Oct 12, 2019 at 11:07
  • $\begingroup$ Traceback (most recent call last): File "\Text", line 9, in <module> AttributeError: 'Scene' object has no attribute 'select_edge_mark' Error: Python script fail, look in the console for now... $\endgroup$
    – Luki Krew
    Commented Oct 12, 2019 at 11:07

1 Answer 1

5
$\begingroup$

Blender 2.80

In order to activate the selection of edge marks you first need to access the Freestyle settings. These settings can be found in the view layer in Blender 2.80. Assuming your view layer is called "View Layer" you can access the settings using the following code:

freestyle_settings = bpy.context.scene.view_layers["View Layer"].freestyle_settings

Alternatively, if you always want to use the active view layer, then you can use the following instead:

freestyle_settings = bpy.context.window.view_layer.freestyle_settings

Next the line sets need to be accessed because the edge mark setting is configurable per line set. Assuming your line set is named "LineSet", you can access it the following way:

lineset = freestyle_settings.linesets["LineSet"]

Alternatively, if you always want to access the active line set, you can use the following instead:

lineset = freestyle_settings.linesets.active

Then you can enable the edge mark selection for the line set.

lineset.select_edge_mark = True

If you don't need access to the freestyle settings or the line set in other parts of your code you can also do this in a one-liner:

bpy.context.scene.view_layers["View Layer"].freestyle_settings.linesets["LineSet"].select_edge_mark = True

The alternative version when relying on the active view layer and line set looks like this:

bpy.context.window.view_layer.freestyle_settings.linesets.active.select_edge_mark = True

Blender 2.79

In order to activate the selection of edge marks you first need to access the Freestyle settings. These settings can be found in the render layer in Blender 2.79. Assuming your render layer is called "RenderLayer" you can access the settings using the following code:

freestyle_settings = bpy.context.scene.render.layers["RenderLayer"].freestyle_settings

Alternatively, if you always want to use the active render layer, then you can use the following instead:

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

The rest is exactly the same as in Blender 2.80.

$\endgroup$
9
  • $\begingroup$ hm, it seems i am to stupid. I have tried to insert one code after the other, error. I tried the combined one, error. I tried the other combined one, error :o Can i send you my code in any way? i dont know how to do. It always says:Traceback (most recent call last): File "\Text", line 19, in <module> AttributeError: 'Scene' object has no attribute 'view_layers' Error: Python script fail, look in the console for now... $\endgroup$
    – Luki Krew
    Commented Oct 12, 2019 at 13:14
  • $\begingroup$ @LukiKrew Are you using Blender 2.79? $\endgroup$ Commented Oct 12, 2019 at 13:18
  • $\begingroup$ yes i am using 2.79 $\endgroup$
    – Luki Krew
    Commented Oct 12, 2019 at 13:23
  • $\begingroup$ The API changed between versions and my code examples are for 2.80. Give me a minute and I'll add the version for 2.79. $\endgroup$ Commented Oct 12, 2019 at 13:25
  • $\begingroup$ Thank you so much rjg if we get trough this i will be so greatful! Also i tried to make an alternative link for saving the export svg files on dekstop, it looks like this: #Render and Export on Desktop shutil.copy(txtName, os.path.join(os.environ["HOMEPATH"], "Desktop")) bpy.context.scene.render.filepath = "~/HOMEPATH/test.svg" bpy.ops.render.render() Any idea how this could be working :)? $\endgroup$
    – Luki Krew
    Commented Oct 12, 2019 at 13:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .