Fix annoying missing texture issue

When getting/setting texel density, use currently open image if object has no image assigned to it
pull/1/head
Andrew Cassidy 4 years ago
parent 22e7aa72b7
commit f6e4f11256
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1

@ -66,10 +66,12 @@ def get_texel_density(self, context):
if image: if image:
object_images[obj] = image object_images[obj] = image
# Warning: No valid images fallback_image = None
if len(object_images) == 0: for area in bpy.context.screen.areas:
self.report({'ERROR_INVALID_INPUT'}, "No Texture found. Assign Checker map or texture first." ) if area.type == 'IMAGE_EDITOR':
return fallback_image = area.spaces[0].image
break
sum_area_vt = 0 sum_area_vt = 0
sum_area_uv = 0 sum_area_uv = 0
@ -82,7 +84,11 @@ def get_texel_density(self, context):
obj.select_set( state = True, view_layer = None) obj.select_set( state = True, view_layer = None)
# Find image of object # Find image of object
image = object_images[obj] if obj in object_images:
image = object_images[obj]
else:
image = fallback_image
if image: if image:
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(obj.data) bm = bmesh.from_edit_mesh(obj.data)

@ -72,11 +72,11 @@ def set_texel_density(self, context, mode, density):
if image: if image:
object_images[obj] = image object_images[obj] = image
# Warning: No valid images fallback_image = None
if len(object_images) == 0: for area in bpy.context.screen.areas:
self.report({'ERROR_INVALID_INPUT'}, if area.type == 'IMAGE_EDITOR':
"No Texture found. Assign Checker map or texture.") fallback_image = area.spaces[0].image
return break
for obj in object_faces: for obj in object_faces:
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
@ -85,7 +85,11 @@ def set_texel_density(self, context, mode, density):
obj.select_set(state=True, view_layer=None) obj.select_set(state=True, view_layer=None)
# Find image of object # Find image of object
image = object_images[obj] if obj in object_images:
image = object_images[obj]
else:
image = fallback_image
if image: if image:
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='EDIT')
bpy.context.scene.tool_settings.use_uv_select_sync = False bpy.context.scene.tool_settings.use_uv_select_sync = False

Loading…
Cancel
Save