1

I desperatly need to clean up some geometry that was previously moddeled in a CAD software. Is there a way to automatically select all the red parts so I can filp them? Recalculating normals does not work and selecting all the faces with "L" will take forever since this is not the only object I have to clean up.

enter image description here

Edit: Select Similar -> Normal also does not work

Luca
  • 49
  • 1
  • 5
  • Edit Mode, with the whole mesh selected Recalculate the normals ( ctrl N ) that should fix the problem (from https://blender.stackexchange.com/a/12174/88382) – Sanbaldo Apr 02 '20 at 07:48
  • It is possible and likely that surfaces coming from CAD software are not continuous, so Recalculate Normals will not work alone in a lot of cases. – Martynas Žiemys Apr 02 '20 at 08:00

3 Answers3

3

If you select all and merge vertices by distance (alt + m) to avoid separate faces, you can then use Recalculate Normals function (shift + n outside, or shift + ctrl + n inside). If that does not work, it means there is simply no way for the algorithms to determine what the right direction might be - if for example you had a few separate planes in random orientations in the mesh of the object, there would be no way to determine what you want to consider the right direction for normals or even what would be consistent for all of the separate planes for your situation without you specifying that. In that case you need to manually select them and set the normals as you like.

Martynas Žiemys
  • 24,274
  • 2
  • 34
  • 77
  • Sadly, merging the verts messes up the geometry. Its strange that there is no way to just select all the red faces since blender has already marked them. – Luca Apr 02 '20 at 08:02
  • 1
    It kind of depends on your end goal. What are you looking to do with the model? Merging vertexes in some cases can help but this requires your model to have somewhat clean topology which CAD software is highly unlikely to generate. I'd first recommend checking the model's scale. Then try merging vertexes with a really small merge distance. Lastly you can try to recalculate the normals. – Delagone Apr 02 '20 at 12:13
0

The best solution I have found is:

  1. Merge Verts
  2. Recalculate Outside
  3. Subdivision Surface to fix broken Geometry
Luca
  • 49
  • 1
  • 5
0

In the case that merging+recalculating normals is not working and in the spirit of providing what OP asked for, I have written a script that will select all the red faces for you.

import bpy
import bmesh

print("=================")

Set to object mode.

bpy.ops.object.mode_set(mode = 'OBJECT')

Get the active object

obj = bpy.context.active_object

faces=[] if obj and obj.type == 'MESH': mesh = bpy.context.active_object # Get selected faces selected_faces = [f.index for f in mesh.data.polygons if f.select]

# Loop through the selected faces.
for face_index in selected_faces:
    face = mesh.data.polygons[face_index]
    normal = face.normal

    # Get location of the current 3d view.
    area = next(area for area in bpy.context.window.screen.areas if area.type == 'VIEW_3D')
    view_location = area.spaces.active.region_3d.view_matrix.inverted().translation


    # modify the view location so that it is at (0,0,0) and calculate 
    # the dot product with the normal.
    dot_product = normal.dot(view_location - face.center)

    # If the dot product is negative then this is a 'red' face.
    if dot_product < 0:
        faces.append(face_index)

# Deselect all faces
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')

# Reselect only the inverted faces.
for face in faces:
    obj.data.polygons[face].select = True

bpy.ops.object.mode_set(mode = 'EDIT')

else: print("No valid mesh object in edit mode found.")

In Face Select mode, select all the faces you want to filter from and then run the script. Only the red faces will be left selected, allowing you to easily flip them. Make sure that your 3D view position is not changed between when you select the faces and run the script, as this position is used in the calculation.

enter image description here

marbs
  • 1
  • 1