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

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

Loading…
Cancel
Save