1
$\begingroup$

I'm trying to make my scripts more low-level and less operator-dependent. One thing that I haven't been able to figure out is this one:

me.use_auto_smooth = True
bpy.ops.mesh.customdata_custom_splitnormals_add()
me.normals_split_custom_set(no_array)

Is there any way to do it without the operator? If so, what's the corresponding low-level code?

$\endgroup$
4
  • $\begingroup$ do you actually want to use custom_split_normals? i'm using it like this: github.com/Aadjou/blender-scripts/blob/master/… $\endgroup$ Commented Sep 19, 2017 at 20:18
  • 1
    $\begingroup$ Yup, I want to set them on a model that had none before. I always thought I first have to create the data layers as from the GUI, hence the operator customdata_custom_splitnormals_add(). Will try your code! $\endgroup$
    – HENDRIX
    Commented Sep 20, 2017 at 21:32
  • $\begingroup$ i was mostly wondering what you want to do with the split normals, because it's super badly supported by blender and you are not able to work with your data much more, i'd avoid it unless you are writing an exporter, in that case you can have a look at this example / line: github.com/archilogic-com/data3d-blender-io/blob/… $\endgroup$ Commented Sep 20, 2017 at 22:37
  • $\begingroup$ Indeed, it is for an importer / exporter combination. The thing is, with the current blender, it seems to work without the operator and even without me.calc_normals_split(). I'm not sure why, but I remember it was not working without the operator in 2.70-ish... $\endgroup$
    – HENDRIX
    Commented Sep 20, 2017 at 23:04

1 Answer 1

0
$\begingroup$

Turns out you don't need the operator at all and I was getting funky results because I had a remove_doubles operation further down the pipeline.

Working example code:

no_array = []
for face in me.polygons:
    for vertex_index in face.vertices:
        no_array.append(mesh_verts[vertex_index][3:6])
    face.use_smooth = True
if use_custom_normals:
    me.use_auto_smooth = True
    me.normals_split_custom_set(no_array)
$\endgroup$

You must log in to answer this question.

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