4
$\begingroup$

I'm struggling with clearing custom split normals data from imported objects. I've found the following script to do it on many objects:

import bpy

selection = bpy.context.selected_objects

for o in selection:
    bpy.context.view_layer.objects.active = o
    bpy.ops.mesh.customdata_custom_splitnormals_clear()

It works but only if the selection does not contain any objects with already cleared custom normals data. Can anyone help me with it? Does the code need some sort of "if" function in it?
That custom normals data often crashes some details in my renders and I would like to repair them all at once.
I have Hard Ops, Fluent and Speedflow addons but I've only found options to clean the mesh or to add autosmooth to selected objects. Am I missing something maybe?
I use Blender 2.8.
Thank you all in advance.

$\endgroup$

1 Answer 1

4
$\begingroup$

I came across this question when I was googling about the same problem. This worked for me.

import bpy

selection = bpy.context.selected_objects

for o in selection:
    bpy.context.view_layer.objects.active = o
    try:
        bpy.ops.mesh.customdata_custom_splitnormals_clear()
    except RuntimeError:
        pass
$\endgroup$

You must log in to answer this question.

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