I have this table : http://my.crazyartzone.com/dmc.asp that I can reduce to keep only the color names and the Hex values on an excel file and I would like to know if it is possible to take that data and get swatches from it instead of making each color one by one.
I know zero things about scripting and the only threads I found are from few years ago and involve the RGB values (which in this case would be almost the same like adding colors one by one)
Thank you in advance for your help!
Are you looking for help learning how to write something like this? Or are you looking for someone to write this?
I'm looking to learn, it would be helpful for future projects too.
fantastic! I don't know how to handle hex colors at this moment either, but ultimately it's all just math and we have the whole internet at our fingertips. we can work through it together. I'll take a look tonight or tomorrow at how we can get started. We could post the whole learning experience here on this thread for posterity.
That would be great! Thank you so much for the help.
I just noticed that the link I left here has the RGB values too ( I mixed it with another site that I was checking earlier) and could make the csv file with the vlues and names but it's quite often that I have to deal with hexa values too
Thank you! your first link did the trick!
However I still want to learn how to do them, seems that will be a great practice
You can do it without scripting. (Although, by all means, do try the scripting route! 🙂 )
Oh, you should turn on 'print background colors' in the print dialogue.
Thank you! The problem with this method is that I need the color names to correspond to each color
Yes, I understand. Especially with such a broad palette, you need those names.
Ok check this out. Let me know if you find this helpful, or if you have any questions or if none of this makes any sense at all.
Thank you so much!
I have some experience with js but didn't know the right way to apply it for illustrator. Please correct me if I am wrong, basically you get the csv file (and do a check to see if a file was called) then split the contents to use them to fill an array that contains all of them, then pick the first position of the array and use it as a name and and for the next position of the array you called a function to turn the hexa values to rgb ones and use those to fill the array right?
Yup. The check after getting the csv file is just to see if the user canceled the file select dialog. If the user cancels the dialog the result will be undefined which makes that condition true and triggers the the script to exit.
So you might be able to imagine how this could be expanded a bit to accommodate more than just hex. You could create rgb, cmyk, spot, or gradient colors using the same techniques here.
Thank you so much!
I'll give it a try adding a check for Hexa, RGB and CMYK colors before the process start and then to apply the proper algorithm to take the values and create the swatches.
Great, very educational script and clean script, thank you so much!
I would have 1 question and 1 comment 🙂
Comment: how to turn an HTML table into a CSV file?
I must say that I find this problem not so trivial, but appearently you ( @Galphath ) have a solution for it. What works for me quite efficiently is select and copy all the cells of the table and pasting them in a new Google Sheets document. (Not Excel, not Pages either) This works like a charm, Google Sheets will just paste it cell-by-cell into a spreadsheet, from which we can easely save as CSV.
Or, we could use a tool like https://www.convertcsv.com/html-table-to-csv.htm (I did not try)
Question: if we have the table, why not use the R, G & B values from it?
Colors are defined by their RGB values, and we have them in the DMC table in the link. Why use the HEX-color through a conversion function and not the RGB-values?
(Both are honest questions, not rhetorical ones)
I'm not sure the best way to convert the html to csv. I've focused more on how to handle a csv after it's been created. I rarely have a need to generate my own data.
If it works to copy/paste the table into google sheets, then that would be my vote for easiest. Because once you have it in sheets, you have all the necessary tools to edit and reformat the data however you want. So that's exciting if it's as easy as copying and pasting.
To your question.. OP originally posted asking for help on converting a table of hex values to swatches in illustrator. They realized that the table they posted included the necessary rgb info, but they said they occasionally have data that is only hex. So it's good to cover one's bases and plan for many different eventualities. As i said, this was more of an educational presentation for a specific task (to someone who said they were inexperienced with scripting).
Basically I wanted to explore how to use hex values to create swatches in illustrator since i've never done that before, and now that I have, I've learned a little bit more and I've become just a little bit more valuable.
I'm rambling at this point so feel free to check out.. haha.
Sometimes my wife will ask what i'm working on when i have my computer out. And often times i'll just reply "just playing". And I don't mean playing games. I truly enjoy just sitting down and testing out different algorithms or exploring new topics. Even if i never end up using many of those tests, each time you go through the process of coding up a solution, you're practicing a ton of really important things which will ultimately make you a better programmer, and a better problem solver in general. Athletes practice daily to get better at what they do. Programmers who do the same will stand out. And I'm looking to stand out. 😉