Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could i use the parser for a blender addon? #2

Open
schroef opened this issue Jan 29, 2020 · 5 comments
Open

Could i use the parser for a blender addon? #2

schroef opened this issue Jan 29, 2020 · 5 comments

Comments

@schroef
Copy link

schroef commented Jan 29, 2020

i was looking into some python to find existing code which can read ASE files. I found some readers for Gimp which use python, but looked to complicated to strip it. After a while i found you code and at first it wasnt working ofcourse cause of the missing swatch_parser. After merging the swatch parser into a single file

However i would to make a addon which will make sort of a palette for Blender.

Is that okay with you? I'll keep most of you code as it, as it simple works and also will add link to your original code ofcourse

@schroef
Copy link
Author

schroef commented Jan 30, 2020

Ps another issue for me on OSX is dot files. OSX creates them and these are read. A simple fix is this when using listdir

if not f.startswith('.'):

@schroef
Copy link
Author

schroef commented Feb 16, 2020

I see blender has this also now as an addon as i was working on mine. I did notice that Photoshop creates a different ASE structure than the one from Adobe Color.

Photoshop created ASE missing main part
What i do noticed is that Photoshop adds RGB values as a name, these are not given in the original ASE file at the bottom

[
    {'name': '242 R, 7 G, 50 B', 'type': 'Global', 'data': {'mode': 'RGB', 'values': [
                0.949999988079071,
                0.02850000001490116,
                0.19744166731834412
            ]
        }
    },
    {'name': '7 R, 3 G, 140 B', 'type': 'Global', 'data': {'mode': 'RGB', 'values': [
                0.028966667130589485,
                0.010999999940395355,
                0.550000011920929
            ]
        }
    },
    {'name': '4 R, 57 G, 217 B', 'type': 'Global', 'data': {'mode': 'RGB', 'values': [
                0.017000000923871994,
                0.2252500057220459,
                0.8500000238418579
            ]
        }
    },
    {'name': '5 R, 108 G, 242 B', 'type': 'Global', 'data': {'mode': 'RGB', 'values': [
                0.01899999938905239,
                0.42243334650993347,
                0.949999988079071
            ]
        }
    },
    {'name': '242 R, 5 G, 5 B', 'type': 'Global', 'data': {'mode': 'RGB', 'values': [
                0.949999988079071,
                0.01899999938905239,
                0.01899999938905239
            ]
        }
    }
]

Its misses the naming part for the ASE swatch

{'name': "Various'", 'type': 'Color Group', 'swatches': [
        {'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
                    0.949999988079071,
                    0.02850000001490116,
                    0.19744166731834412
                ]
            }
        },
        {'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
                    0.028966667130589485,
                    0.010999999940395355,
                    0.550000011920929
                ]
            }
        },
        {'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
                    0.017000000923871994,
                    0.2252500057220459,
                    0.8500000238418579
                ]
            }
        },
        {'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
                    0.01899999938905239,
                    0.42243334650993347,
                    0.949999988079071
                ]
            }
        },
        {'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
                    0.949999988079071,
                    0.01899999938905239,
                    0.01899999938905239
                ]
            }
        }
    ]
}
]
[
{'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
            0.949999988079071,
            0.02850000001490116,
            0.19744166731834412
        ]
    }
},
{'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
            0.028966667130589485,
            0.010999999940395355,
            0.550000011920929
        ]
    }
},
{'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
            0.017000000923871994,
            0.2252500057220459,
            0.8500000238418579
        ]
    }
},
{'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
            0.01899999938905239,
            0.42243334650993347,
            0.949999988079071
        ]
    }
},
{'name': '', 'type': 'Process', 'data': {'mode': 'RGB', 'values': [
            0.949999988079071,
            0.01899999938905239,
            0.01899999938905239
        ]
    }
}
]

@schroef
Copy link
Author

schroef commented Feb 17, 2020

Thinking about this, i think you already have this figured out. You loop of the function itself by calling the function again with swatch['swatches']. The devs from Blender stripped this part thinking it was for the CSS generator i guess. I added a diferent approach

if 'swatches' in swatch:
            for data in swatch['swatches']:
                mode = data['data']['mode']
                val = data['data']['values']
                valid = False
                pal = makePalette(context, mode, val, filename, valid, pal, color) #reuse same palette generation code

        else:
            mode = swatch['data']['mode']
            val = swatch['data']['values']
            valid = False
            pal = makePalette(context, mode, val, filename, valid, pal, color) #reuse same palette generation code  

@nsfmc
Copy link
Owner

nsfmc commented Jan 4, 2021

@schroef hey, i'm super sorry i missed this whole discussion, do you want to pick it up again?

@schroef
Copy link
Author

schroef commented Apr 30, 2021

@nsfmc Now im late to the game as well.. I got it all working and im trying to add more functionality. I the importer in blender is still broken for ASE. I did not know how to use the blender git. Still reading about that part.

What i wanted to do is save the first import so a user can also revert back to the original order of the palette. I havent worked on it since last year since my laptop died back then. Near the end of the year i finally got a new one but took me some time to adjust to Windows again since i had been on OSX for 17 years or so.

Im doing some other addons at the moment but i hope to pick this one up soonl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants