Created
April 7, 2019 15:43
-
-
Save robgithub/d5045fac793102549b11d88c7122080a to your computer and use it in GitHub Desktop.
Blender UV unwrap from view all selected Meshes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You saved my year thx.