4

due to a sketchup import half my objects are inside out

how can i make a script (novice) that selects all objects (one by one?), put them in edit mode, recalculate outside (cntl n) and back into object mode.

Alexander
  • 41
  • 3

1 Answers1

4

The easiest way to approach the building of a script if you are not keen on python coding would be to perform all the tasks you need, then copy the command that shows up in the info editor and paste in a loop that iterate through all the objects.

enter image description here

Here's a possible code:

import bpy

if bpy.context.selected_objects != []:
    for obj in bpy.context.selected_objects: #loop through all the selected objects
        if obj.type == 'MESH':
            bpy.context.scene.objects.active = obj
            bpy.ops.object.editmode_toggle() #enter edit mode
            bpy.ops.mesh.select_all(action='SELECT') #select all objects elements
            bpy.ops.mesh.normals_make_consistent(inside=False) #recalc normals
            bpy.ops.object.editmode_toggle() #exit edit mode

Here's the script in action:

enter image description here

Carlo
  • 24,826
  • 2
  • 49
  • 92