bl_info = {
"name": "Combine UV Maps",
"blender": (3, 0, 0),
"category": "UV",
"description": "Combine multiple UV maps into a single UV map",
"author": "Your Name",
"version": (1, 0),
}
class UV_OT_CombineUVMaps(bpy.types.Operator):
bl_idname = "uv.combine_uv_maps"
bl_label = "Combine UV Maps"
bl_description = "Combine multiple UV maps into a single UV map"
bl_options = {'REGISTER', 'UNDO'}
code
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="CombinedUVMap"
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to combine.")
return {'CANCELLED'}
# Create a new UV map or clear the existing one
if self.target_uv_map in me.uv_layers:
target_uv_layer = me.uv_layers[self.target_uv_map]
else:
target_uv_layer = me.uv_layers.new(name=self.target_uv_map)
# Set the new UV map as active
me.uv_layers.active = target_uv_layer
target_uv_layer.active_render = True
# Combine UVs from all layers into the target UV map
for loop in me.loops:
for uv_layer in me.uv_layers:
if uv_layer.name != self.target_uv_map:
target_uv_layer.data[loop.index].uv = uv_layer.data[loop.index].uv
break
self.report({'INFO'}, f"Combined UV maps into {self.target_uv_map}.")
return {'FINISHED'}
bl_info = {
"name": "Combine UV Maps",
"blender": (3, 0, 0),
"category": "UV",
"description": "Combine multiple UV maps into a single UV map",
"author": "Your Name",
"version": (1, 1),
}
class UV_OT_CombineUVMaps(bpy.types.Operator):
bl_idname = "uv.combine_uv_maps"
bl_label = "Combine UV Maps"
bl_description = "Combine multiple UV maps into a single UV map"
bl_options = {'REGISTER', 'UNDO'}
code
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="CombinedUVMap"
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to combine.")
return {'CANCELLED'}
# Create a new UV map or clear the existing one
if self.target_uv_map in me.uv_layers:
target_uv_layer = me.uv_layers[self.target_uv_map]
else:
target_uv_layer = me.uv_layers.new(name=self.target_uv_map)
# Set the new UV map as active
me.uv_layers.active = target_uv_layer
target_uv_layer.active_render = True
# Combine UVs from all layers into the target UV map
for loop in me.loops:
for uv_layer in me.uv_layers:
if uv_layer.name != self.target_uv_map:
target_uv_layer.data[loop.index].uv = uv_layer.data[loop.index].uv
break
self.report({'INFO'}, f"Combined UV maps into {self.target_uv_map}.")
return {'FINISHED'}
bl_info = {
"name": "Combine UV Maps Improved",
"blender": (3, 0, 0),
"category": "UV",
"description": "Combine multiple UV maps into a single UV map with correct UV coordinates",
"author": "Your Name",
"version": (1, 2),
}
class .Operator):
bl_idname = "uv.combine_uv_maps_improved"
bl_label = "Combine UV Maps Improved"
bl_description = "Combine multiple UV maps into a single UV map with correct UV coordinates"
bl_options = {'REGISTER', 'UNDO'}
code
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="CombinedUVMap"
)
remove_old_uv_maps: bpy.props.BoolProperty(
name="Remove Old UV Maps",
description="Remove old UV maps after combining",
default=False
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to combine.")
return {'CANCELLED'}
# Create or get the target UV map
if self.target_uv_map in me.uv_layers:
target_uv_layer = me.uv_layers[self.target_uv_map]
else:
target_uv_layer = me.uv_layers.new(name=self.target_uv_map)
# Make the target UV map active
me.uv_layers.active = target_uv_layer
target_uv_layer.active_render = True
# Store UV data temporarily
combined_uvs = [None] * len(me.loops)
# Combine UVs from all layers into the combined_uvs list
for uv_layer in me.uv_layers:
if uv_layer.name != self.target_uv_map:
for i, loop in enumerate(me.loops):
combined_uvs[loop.index] = <REDACTED>()
# Assign the combined UVs to the target UV map
for i, loop in enumerate(me.loops):
if combined_uvs[loop.index] is not None:
target_uv_layer.data[loop.index].uv = combined_uvs[loop.index]
# Remove old UV maps if the option is enabled
if self.remove_old_uv_maps:
uv_layers_to_remove = [uv_layer for uv_layer in me.uv_layers if uv_layer.name != self.target_uv_map]
for uv_layer in uv_layers_to_remove:
me.uv_layers.remove(uv_layer)
self.report({'INFO'}, f"Combined UV maps into {self.target_uv_map}.")
return {'FINISHED'}
bl_info = {
"name": "Merge UV Maps",
"blender": (3, 0, 0),
"category": "UV",
"description": "Merge multiple UV maps into a single UV map by maintaining all UV information",
"author": "Your Name",
"version": (1, 0),
}
class UV_OT_MergeUVMaps(bpy.types.Operator):
bl_idname = "uv.merge_uv_maps"
bl_label = "Merge UV Maps"
bl_description = "Merge multiple UV maps into a single UV map"
bl_options = {'REGISTER', 'UNDO'}
code
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="MergedUVMap"
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to merge.")
return {'CANCELLED'}
# Check if the target UV map already exists and create a new one if it doesn't
if self.target_uv_map in me.uv_layers:
target_uv_layer = me.uv_layers[self.target_uv_map]
else:
target_uv_layer = me.uv_layers.new(name=self.target_uv_map)
# Set the target UV map as active
me.uv_layers.active = target_uv_layer
target_uv_layer.active_render = True
# Create a BMesh for editing UVs
bm = bmesh.new()
<REDACTED>
uv_layers = {layer.name: bm.loops.layers.uv[layer.name] for layer in me.uv_layers}
# Create a new UV layer in BMesh for the target UV map
uv_layer_target = bm.loops.layers.uv[self.target_uv_map]
# Iterate over all faces and loops, merging UVs into the target UV map
for face in bm.faces:
for loop in face.loops:
combined_uv = <REDACTED>()
for layer_name, uv_layer in uv_layers.items():
if layer_name != self.target_uv_map:
combined_uv += loop[uv_layer]
combined_uv /= (len(uv_layers) - 1)
loop[uv_layer_target].uv = combined_uv
# Update the mesh with the merged UV data
bm.to_mesh(me)
bm.free()
self.report({'INFO'}, f"UV maps merged into {self.target_uv_map}.")
return {'FINISHED'}
User
アドオンを実行すると以下のエラーが出されました。修正できますか?
Python: Traceback (most recent call last):
File "C:\Users\splal\AppData\Roaming\Blender Foundation\Blender\4.2\scripts\addons\UV_Combine.py", line 61, in execute
combined_uv = ()
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'BMLoopUV' object has no attribute 'copy'
bl_info = {
"name": "Merge UV Maps",
"blender": (3, 0, 0),
"category": "UV",
"description": "Merge multiple UV maps into a single UV map by maintaining all UV information",
"author": "Your Name",
"version": (1, 1),
}
class UV_OT_MergeUVMaps(bpy.types.Operator):
bl_idname = "uv.merge_uv_maps"
bl_label = "Merge UV Maps"
bl_description = "Merge multiple UV maps into a single UV map"
bl_options = {'REGISTER', 'UNDO'}
code
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="MergedUVMap"
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to merge.")
return {'CANCELLED'}
# Check if the target UV map already exists and create a new one if it doesn't
if self.target_uv_map in me.uv_layers:
target_uv_layer = me.uv_layers[self.target_uv_map]
else:
target_uv_layer = me.uv_layers.new(name=self.target_uv_map)
# Set the target UV map as active
me.uv_layers.active = target_uv_layer
target_uv_layer.active_render = True
# Create a BMesh for editing UVs
bm = bmesh.new()
<REDACTED>
uv_layers = {layer.name: bm.loops.layers.uv[layer.name] for layer in me.uv_layers}
# Create a new UV layer in BMesh for the target UV map
uv_layer_target = bm.loops.layers.uv[self.target_uv_map]
# Iterate over all faces and loops, merging UVs into the target UV map
for face in bm.faces:
for loop in face.loops:
combined_uv = [0.0, 0.0]
count = 0
for layer_name, uv_layer in uv_layers.items():
if layer_name != self.target_uv_map:
combined_uv[0] += loop[uv_layer].uv[0]
combined_uv[1] += loop[uv_layer].uv[1]
count += 1
# Average the UVs to get the final combined UV
if count > 0:
combined_uv[0] /= count
combined_uv[1] /= count
loop[uv_layer_target].uv = (combined_uv[0], combined_uv[1])
# Update the mesh with the merged UV data
bm.to_mesh(me)
bm.free()
self.report({'INFO'}, f"UV maps merged into {self.target_uv_map}.")
return {'FINISHED'}
bl_info = {
"name": "Merge UV Maps (Preserve Scale)",
"blender": (3, 0, 0),
"category": "UV",
"description": "Merge multiple UV maps into a single UV map, preserving original UV island sizes",
"author": "Your Name",
"version": (1, 2),
}
class UV_OT_MergeUVMapsPreserveScale(bpy.types.Operator):
bl_idname = "uv.merge_uv_maps_preserve_scale"
bl_label = "Merge UV Maps (Preserve Scale)"
bl_description = "Merge multiple UV maps into a single UV map, preserving original UV island sizes"
bl_options = {'REGISTER', 'UNDO'}
code
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="MergedUVMap"
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to merge.")
return {'CANCELLED'}
# Create a BMesh for editing UVs
bm = bmesh.new()
<REDACTED># Store UV layers information in BMesh
uv_layers = {layer.name: bm.loops.layers.uv[layer.name] for layer in me.uv_layers}
# Check if the target UV map already exists and create a new one if it doesn't
if self.target_uv_map in me.uv_layers:
target_uv_layer = bm.loops.layers.uv[self.target_uv_map]
else:
target_uv_layer = bm.loops.layers.uv.new(self.target_uv_map)
# Iterate over all faces and loops, merging UVs into the target UV map
for face in bm.faces:
for loop in face.loops:
# Get the original UV value from each UV map (use the first UV map as the base)
base_uv = None
for layer_name, uv_layer in uv_layers.items():
if layer_name != self.target_uv_map:
base_uv = loop[uv_layer].uv
break
if base_uv:
# Set the UV in the target UV map to the base UV value without scaling or averaging
loop[target_uv_layer].uv = base_uv
# Update the mesh with the merged UV data
bm.to_mesh(me)
bm.free()
# Update the mesh with the merged UV data
bpy.context.view_layer.objects.active = obj
obj.data.update()
self.report({'INFO'}, f"UV maps merged into {self.target_uv_map}, preserving original sizes.")
return {'FINISHED'}
pythonCopy codeimport bpy
import bmesh
from mathutils import Vector
bl_info = {
"name": "Merge UV Maps with Scaling",
"blender": (3, 0, 0),
"category": "UV",
"description": "Merge multiple UV maps into a single UV map and scale the merged UV islands",
"author": "Your Name",
"version": (1, 3),
}
class UV_OT_MergeUVMapsWithScaling(bpy.types.Operator):
bl_idname = "uv.merge_uv_maps_with_scaling"
bl_label = "Merge UV Maps with Scaling"
bl_description = "Merge multiple UV maps into a single UV map and scale the merged UV islands"
bl_options = {'REGISTER', 'UNDO'}
pythonCopy codeimport bpy
import bmesh
from mathutils import Vector
bl_info = {
"name": "Merge UV Maps with Cursor Scaling",
"blender": (3, 0, 0),
"category": "UV",
"description": "Merge multiple UV maps into a single UV map and scale the merged UV islands using the cursor as the pivot",
"author": "Your Name",
"version": (1, 4),
}
class UV_OT_MergeUVMapsWithCursorScaling(bpy.types.Operator):
bl_idname = "uv.merge_uv_maps_with_cursor_scaling"
bl_label = "Merge UV Maps with Cursor Scaling"
bl_description = "Merge multiple UV maps into a single UV map and scale the merged UV islands using the cursor as the pivot"
bl_options = {'REGISTER', 'UNDO'}
pythonCopy codeimport bpy
import bmesh
from mathutils import Vector
bl_info = {
"name": "Merge UV Maps with Cursor Scaling (Edit Mode Support)",
"blender": (3, 0, 0),
"category": "UV",
"description": "Merge multiple UV maps into a single UV map and scale the merged UV islands using the cursor as the pivot. Supports Edit Mode.",
"author": "Your Name",
"version": (1, 5),
}
class UV_OT_MergeUVMapsWithCursorScalingEditMode(bpy.types.Operator):
bl_idname = "uv.merge_uv_maps_with_cursor_scaling_edit_mode"
bl_label = "Merge UV Maps with Cursor Scaling (Edit Mode)"
bl_description = "Merge multiple UV maps into a single UV map and scale the merged UV islands using the cursor as the pivot. Supports Edit Mode."
bl_options = {'REGISTER', 'UNDO'}
code
User
完璧です!ありがとうございました!
Assistant
!🎨✨
Cite this conversation
“複数のUVマップを一つのUVマップに統合するアドオンを作ってほしいです.” Conversation with ChatGPT (version unspecified), from the ShareChat — Chatbot Conversations in the Wild dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m84v085rkqw9vj5gn69pb80v
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="MergedUVMap"
)
scale_factor: bpy.props.FloatProperty(
name="Scale Factor",
description="Factor by which to scale the merged UV islands",
default=2.0,
min=0.1,
max=10.0
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to merge.")
return {'CANCELLED'}
# Create a BMesh for editing UVs
bm = bmesh.new()
<REDACTED># Store UV layers information in BMesh
uv_layers = {layer.name: bm.loops.layers.uv[layer.name] for layer in me.uv_layers}
# Check if the target UV map already exists and create a new one if it doesn't
if self.target_uv_map in me.uv_layers:
target_uv_layer = bm.loops.layers.uv[self.target_uv_map]
else:
target_uv_layer = bm.loops.layers.uv.new(self.target_uv_map)
# Iterate over all faces and loops, merging UVs into the target UV map
for face in bm.faces:
for loop in face.loops:
combined_uv = [0.0, 0.0]
count = 0
for layer_name, uv_layer in uv_layers.items():
if layer_name != self.target_uv_map:
combined_uv[0] += loop[uv_layer].uv[0]
combined_uv[1] += loop[uv_layer].uv[1]
count += 1
# Average the UVs to get the final combined UV
if count > 0:
combined_uv[0] /= count
combined_uv[1] /= count
loop[target_uv_layer].uv = (combined_uv[0], combined_uv[1])
# Apply scaling to the merged UV map
<REDACTED>, target_uv_layer, self.scale_factor)
# Update the mesh with the merged UV data
bm.to_mesh(me)
bm.free()
self.report({'INFO'}, f"UV maps merged into {self.target_uv_map} and scaled by <REDACTED>.")
return {'FINISHED'}
def scale_uv_map(self, bm, uv_layer, scale_factor):
# Calculate the center of all UVs
uv_center = Vector((0.0, 0.0))
uv_count = 0
for face in bm.faces:
for loop in face.loops:
uv_center += loop[uv_layer].uv
uv_count += 1
if uv_count > 0:
uv_center /= uv_count
# Scale UVs around the center
for face in bm.faces:
for loop in face.loops:
loop_uv = loop[uv_layer].uv
# Scale the UV coordinates around the center
loop[uv_layer].uv = uv_center + (loop_uv - uv_center) * scale_factor
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="MergedUVMap"
)
scale_factor: bpy.props.FloatProperty(
name="Scale Factor",
description="Factor by which to scale the merged UV islands",
default=2.0,
min=0.1,
max=10.0
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to merge.")
return {'CANCELLED'}
# Create a BMesh for editing UVs
bm = bmesh.new()
<REDACTED># Store UV layers information in BMesh
uv_layers = {layer.name: bm.loops.layers.uv[layer.name] for layer in me.uv_layers}
# Check if the target UV map already exists and create a new one if it doesn't
if self.target_uv_map in me.uv_layers:
target_uv_layer = bm.loops.layers.uv[self.target_uv_map]
else:
target_uv_layer = bm.loops.layers.uv.new(self.target_uv_map)
# Iterate over all faces and loops, merging UVs into the target UV map
for face in bm.faces:
for loop in face.loops:
combined_uv = [0.0, 0.0]
count = 0
for layer_name, uv_layer in uv_layers.items():
if layer_name != self.target_uv_map:
combined_uv[0] += loop[uv_layer].uv[0]
combined_uv[1] += loop[uv_layer].uv[1]
count += 1
# Average the UVs to get the final combined UV
if count > 0:
combined_uv[0] /= count
combined_uv[1] /= count
loop[target_uv_layer].uv = (combined_uv[0], combined_uv[1])
# Apply scaling to the merged UV map using the cursor as the pivot
self.scale_uv_map_with_cursor(bm, target_uv_layer, self.scale_factor)
# Update the mesh with the merged UV data
bm.to_mesh(me)
bm.free()
self.report({'INFO'}, f"UV maps merged into {self.target_uv_map} and scaled by {self.scale_factor} using cursor as pivot.")
return {'FINISHED'}
def scale_uv_map_with_cursor(self, bm, uv_layer, scale_factor):
# Get the UV cursor location
cursor_location = bpy.context.scene.cursor.location
# Get the cursor location in UV space (UV Editor cursor is stored in view space, need to map it)
<REDACTED> = Vector((cursor_location.x, cursor_location.y))
# Scale UVs around the cursor position
for face in bm.faces:
for loop in face.loops:
loop_uv = loop[uv_layer].uv
# Scale the UV coordinates around the cursor
loop[uv_layer].uv = uv_cursor + (loop_uv - uv_cursor) * scale_factor
target_uv_map: bpy.props.StringProperty(
name="Target UV Map",
description="Name of the target UV map",
default="MergedUVMap"
)
scale_factor: bpy.props.FloatProperty(
name="Scale Factor",
description="Factor by which to scale the merged UV islands",
default=2.0,
min=0.1,
max=10.0
)
@classmethod
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'MESH'
def execute(self, context):
obj = context.active_object
me = obj.data
# Store the current mode
current_mode = bpy.context.object.mode
# Switch to Object Mode if in Edit Mode
if current_mode == 'EDIT':
bpy.ops.object.mode_set(mode='OBJECT')
# Check if there are multiple UV maps
if len(me.uv_layers) < 2:
self.report({'WARNING'}, "The object must have at least two UV maps to merge.")
return {'CANCELLED'}
# Create a BMesh for editing UVs
bm = bmesh.new()
<REDACTED># Store UV layers information in BMesh
uv_layers = {layer.name: bm.loops.layers.uv[layer.name] for layer in me.uv_layers}
# Check if the target UV map already exists and create a new one if it doesn't
if self.target_uv_map in me.uv_layers:
target_uv_layer = bm.loops.layers.uv[self.target_uv_map]
else:
target_uv_layer = bm.loops.layers.uv.new(self.target_uv_map)
# Iterate over all faces and loops, merging UVs into the target UV map
for face in bm.faces:
for loop in face.loops:
combined_uv = [0.0, 0.0]
count = 0
for layer_name, uv_layer in uv_layers.items():
if layer_name != self.target_uv_map:
combined_uv[0] += loop[uv_layer].uv[0]
combined_uv[1] += loop[uv_layer].uv[1]
count += 1
# Average the UVs to get the final combined UV
if count > 0:
combined_uv[0] /= count
combined_uv[1] /= count
loop[target_uv_layer].uv = (combined_uv[0], combined_uv[1])
# Apply scaling to the merged UV map using the cursor as the pivot
self.scale_uv_map_with_cursor(bm, target_uv_layer, self.scale_factor)
# Update the mesh with the merged UV data
bm.to_mesh(me)
bm.free()
# Switch back to Edit Mode if we were originally in Edit Mode
if current_mode == 'EDIT':
bpy.ops.object.mode_set(mode='EDIT')
self.report({'INFO'}, f"UV maps merged into {self.target_uv_map} and scaled by {self.scale_factor} using cursor as pivot.")
return {'FINISHED'}
def scale_uv_map_with_cursor(self, bm, uv_layer, scale_factor):
# Get the UV cursor location
cursor_location = bpy.context.scene.cursor.location
# Get the cursor location in UV space (UV Editor cursor is stored in view space, need to map it)
<REDACTED> = Vector((cursor_location.x, cursor_location.y))
# Scale UVs around the cursor position
for face in bm.faces:
for loop in face.loops:
loop_uv = loop[uv_layer].uv
# Scale the UV coordinates around the cursor
loop[uv_layer].uv = uv_cursor + (loop_uv - uv_cursor) * scale_factor