1
0
mirror of https://github.com/drewcassidy/TexTools-Blender synced 2024-06-11 00:26:53 +00:00
Blender-TexTools/op_color_io_export.py

44 lines
1.1 KiB
Python
Raw Normal View History

2019-06-08 23:42:50 +00:00
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):
2019-12-18 20:53:16 +00:00
bl_idname = "uv.textools_color_io_export"
bl_label = "Export"
bl_description = "Export current color palette to clipboard"
2019-06-08 23:42:50 +00:00
2019-12-18 20:53:16 +00:00
@classmethod
def poll(cls, context):
2019-12-24 19:59:46 +00:00
# Only in UV editor mode
2019-12-18 20:53:16 +00:00
if bpy.context.area.type != 'IMAGE_EDITOR':
return False
2019-06-08 23:42:50 +00:00
2019-12-18 20:53:16 +00:00
return True
2019-12-24 19:59:46 +00:00
2019-12-18 20:53:16 +00:00
def execute(self, context):
export_colors(self, context)
return {'FINISHED'}
2019-06-08 23:42:50 +00:00
def export_colors(self, context):
2019-12-24 19:59:46 +00:00
2019-12-18 20:53:16 +00:00
hex_colors = []
for i in range(bpy.context.scene.texToolsSettings.color_ID_count):
2019-12-24 19:59:46 +00:00
color = getattr(bpy.context.scene.texToolsSettings,
"color_ID_color_{}".format(i))
hex_colors.append(utilities_color.color_to_hex(color))
2019-12-18 20:53:16 +00:00
bpy.context.window_manager.clipboard = ", ".join(hex_colors)
2019-12-24 19:59:46 +00:00
bpy.ops.ui.textools_popup(
'INVOKE_DEFAULT', message="{}x colors copied to clipboard".format(len(hex_colors)))
2019-06-08 23:42:50 +00:00
2019-12-24 19:59:46 +00:00
bpy.utils.register_class(op)