You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Blender-TexTools/op_color_io_export.py

44 lines
1.1 KiB
Python

import bpy
import bmesh
import operator
from mathutils import Vector
from collections import defaultdict
from math import pi
from . import utilities_color
class op(bpy.types.Operator):
4 years ago
bl_idname = "uv.textools_color_io_export"
bl_label = "Export"
bl_description = "Export current color palette to clipboard"
4 years ago
@classmethod
def poll(cls, context):
4 years ago
# Only in UV editor mode
4 years ago
if bpy.context.area.type != 'IMAGE_EDITOR':
return False
4 years ago
return True
4 years ago
4 years ago
def execute(self, context):
export_colors(self, context)
return {'FINISHED'}
def export_colors(self, context):
4 years ago
4 years ago
hex_colors = []
for i in range(bpy.context.scene.texToolsSettings.color_ID_count):
4 years ago
color = getattr(bpy.context.scene.texToolsSettings,
"color_ID_color_{}".format(i))
hex_colors.append(utilities_color.color_to_hex(color))
4 years ago
bpy.context.window_manager.clipboard = ", ".join(hex_colors)
4 years ago
bpy.ops.ui.textools_popup(
'INVOKE_DEFAULT', message="{}x colors copied to clipboard".format(len(hex_colors)))
4 years ago
bpy.utils.register_class(op)