Fix #104401: Import .ase files with swatch groups #104405
@ -2,8 +2,8 @@
|
||||
|
||||
bl_info = {
|
||||
"name": "Import Palettes",
|
||||
"author": "Antonio Vazquez",
|
||||
"version": (1, 0, 0),
|
||||
"author": "Antonio Vazquez, Kevin C. Burke (@blastframe)",
|
||||
"version": (1, 0, 1),
|
||||
"blender": (2, 81, 6),
|
||||
"location": "File > Import",
|
||||
"description": "Import Palettes",
|
||||
|
@ -99,16 +99,9 @@ def parse(filename):
|
||||
return [c for c in parse_chunk(data)]
|
||||
|
||||
|
||||
def load(context, filepath):
|
||||
output = parse(filepath)
|
||||
def create_color(data):
|
||||
|
||||
(path, filename) = os.path.split(filepath)
|
||||
|
||||
pal = None
|
||||
|
||||
for elm in output:
|
||||
valid = False
|
||||
data = elm['data']
|
||||
color = [0, 0, 0]
|
||||
val = data['values']
|
||||
|
||||
@ -128,12 +121,31 @@ def load(context, filepath):
|
||||
color[1] = (1.0 - val[1]) * (1.0 - val[3])
|
||||
color[2] = (1.0 - val[2]) * (1.0 - val[3])
|
||||
|
||||
# Create palette color
|
||||
if valid:
|
||||
return color
|
||||
|
||||
def load(context, filepath):
|
||||
output = parse(filepath)
|
||||
|
||||
(path, filename) = os.path.split(filepath)
|
||||
|
||||
pal = None
|
||||
|
||||
for elm in output:
|
||||
colors = []
|
||||
|
||||
if "data" in elm:
|
||||
colors.append(create_color(elm['data']))
|
||||
|
||||
if "swatches" in elm:
|
||||
for swatch in elm['swatches']:
|
||||
colors.append(create_color(swatch["data"]))
|
||||
|
||||
# Create Palette
|
||||
if pal is None:
|
||||
pal = bpy.data.palettes.new(name=filename)
|
||||
|
||||
for color in colors:
|
||||
# Create Color
|
||||
col = pal.colors.new()
|
||||
col.color[0] = color[0]
|
||||
|
Loading…
Reference in New Issue
Block a user