Skip to content

Instantly share code, notes, and snippets.

@pwillard
Last active January 9, 2024 18:13
Show Gist options
  • Save pwillard/e40544333b1842cd0fd9aa95d2ad9d16 to your computer and use it in GitHub Desktop.
Save pwillard/e40544333b1842cd0fd9aa95d2ad9d16 to your computer and use it in GitHub Desktop.
Blender Python Fix for NAVS OBJ Import
import bpy
# Get selected objects
selected_objects = bpy.context.selected_objects
if selected_objects:
# Iterate through each selected object
for obj in selected_objects:
# Select the object
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
# Check if the object has custom split normals data
if obj.data.use_auto_smooth or obj.data.has_custom_normals:
# Clear custom split normals data
bpy.ops.mesh.customdata_custom_splitnormals_clear()
# Apply Smooth Shading
bpy.ops.object.shade_smooth()
# Enable Auto Smooth
bpy.context.object.data.use_auto_smooth = True
# Apply rotation and scale
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
# Deselect the object
obj.select_set(False)
else:
print("No objects selected.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment