diff --git a/add_mesh_extra_objects/add_mesh_solid.py b/add_mesh_extra_objects/add_mesh_solid.py index ef9cc541d..db72651c5 100644 --- a/add_mesh_extra_objects/add_mesh_solid.py +++ b/add_mesh_extra_objects/add_mesh_solid.py @@ -325,6 +325,26 @@ def createSolid(plato, vtrunc, etrunc, dual, snub): return dvOutput, dfOutput +def fixup_normals(obj): + """ + Some of the presets have their faces with wrong normals. This fixes them. + """ + curr_active = bpy.context.view_layer.objects.active + + # Select new object, + bpy.ops.object.select_all(action='DESELECT') + obj.select_set(True) + bpy.context.view_layer.objects.active = obj + + bpy.ops.object.mode_set(mode='EDIT') + bpy.ops.mesh.select_all(action='SELECT') # select all faces + bpy.ops.mesh.normals_make_consistent(inside=False) + bpy.ops.object.editmode_toggle() # return to object mode + + # Reset to previously active + bpy.context.view_layer.objects.active = curr_active + + class Solids(bpy.types.Operator): """Add one of the (regular) solids (mesh)""" bl_idname = "mesh.primitive_solid_add" @@ -509,7 +529,10 @@ class Solids(bpy.types.Operator): # Update mesh geometry after adding stuff. mesh.update() - object_data_add(context, mesh, operator=None) + obj = object_data_add(context, mesh, operator=None) + + fixup_normals(obj) + # object generation done return {'FINISHED'}