Skip to content

Instantly share code, notes, and snippets.

@robgithub
Created April 7, 2019 15:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robgithub/d5045fac793102549b11d88c7122080a to your computer and use it in GitHub Desktop.
Save robgithub/d5045fac793102549b11d88c7122080a to your computer and use it in GitHub Desktop.
Blender UV unwrap from view all selected Meshes
#UV unwrap from view all selected Meshes
import bpy
def unwrap_from_view(TARGET):
bpy.context.scene.objects.active = bpy.data.objects[TARGET]
bpy.context.object.name = TARGET
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'SELECT')
for oWindow in bpy.context.window_manager.windows:
oScreen = oWindow.screen
for oArea in oScreen.areas:
if oArea.type == 'VIEW_3D':
for oRegion in oArea.regions:
if oRegion.type == 'WINDOW':
override = {'window': oWindow, 'screen': oScreen, 'area': oArea, 'region': oRegion, 'scene': bpy.context.scene, 'edit_object': bpy.context.edit_object, 'active_object': bpy.context.active_object, 'selected_objects': bpy.context.selected_objects}
bpy.ops.uv.project_from_view(override , camera_bounds=True, correct_aspect=False, scale_to_bounds=False)
bpy.ops.object.mode_set(mode = 'OBJECT')
for obj in bpy.context.selected_objects:
if obj.type == 'MESH':
unwrap_from_view(obj.name)
@Mephisto405
Copy link

Mephisto405 commented Apr 11, 2024

You saved my year thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment