Browse Source

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 1 year ago
parent
commit
f6e4f11256
No known key found for this signature in database GPG Key ID: 963017B38FD477A1
2 changed files with 21 additions and 11 deletions
  1. +11
    -5
      op_texel_density_get.py
  2. +10
    -6
      op_texel_density_set.py

+ 11
- 5
op_texel_density_get.py View File

@ -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)


+ 10
- 6
op_texel_density_set.py View File

@ -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