Working with mesh edges marked for rendering using the Freestyle render engine

To create line-based renderings, such as blueprints or 3D to 2D stylizations, an additional “Freestyle” render engine is usually used with the main render engine. Edges that should be clearly outlined in the final render must be marked as “freestyle” so that the Freestyle render engine can process them.

As with almost all mesh structure in Blender, “freestyle” marked edges can be processed using the Blender Python API.

Each mesh edge has a “use_freestyle_mark” property, which determines whether the edge is marked as “freestyle” – the value is True, or not – False.

We can check the value of this property for one edge of the active mesh:

Or get a list of all its edges marked as “freestyle”:

To mark an edge as “freestyle”, we can simply change the value of this property. For example, let’s mark “freestyle” all edges with indices from 100 to 300. The mesh must be in Object mode.

Working with the “freestyle” edge property using a bmesh object presents some challenges.

Although the bmesh object has a “freestyle” layer for edges, and we can get a separate data layer for “freestyle”,

the data structure returns us a NotImplemented error.

We can control whether an edge is marked as “freestyle” when working with a bmesh object by relating the edge indices of the base mesh and the bmesh.

First, we get the indexes of the edges marked “freestyle” from the base mesh:

Then, in the bmesh object, we can check whether the index of the current edge matches the resulting set of edge indices.

0 0 votes
Article Rating
Notify of

0 Comment
Inline Feedbacks
View all comments