Copy link to clipboard
Copied
Hi All,
I am no programmer by any means nor am I a speadsheet guru but I have recently got some data on Google Sheets that I want to use to make life MUCH easier. I want to tell Illustrator to look at the spreadsheet know how many object to create, how far to move them and then how much to rotate them by on a given coordinate … but I don't know the first thing about how to tackle it.
I have been using Illustrator since I was 16 (I'm now 40!) and I have never touched Variable Data, importing spreadsheets data, or Actions (I used Actions in PShop years ago) … and I suspect I probably have to use one or a combination of these to get my desired result. Can any kind soul point me in the right direction?
My convivial thanks in advance!
Copy link to clipboard
Copied
Thanks René but I believed the clarity of my request was there from the start. You are the first to suggest illustrating it, earlier suggestions referred to files that I don't have.
In the spirit of your example, I attach the process which explains the process visually, as that appears to be the preferred means of communication.
Copy link to clipboard
Copied
Thanks pixel, yes that is what I was describing. My focus has been on how you script that. I have a list of data that needs to be read and an object, of whatever description, be plotted repeatedly around. I think I have exhausted explaining now, I cannot put it any other way. I have just posted another response with an attachment which hopefully articulates the process I described earlier.
Copy link to clipboard
Copied
Things are moving slowly forwards.
Scripts (and actions) are efficient - but both are stupid. They do exactly as they are told. But exactly that. Nothing more and nothing less. A precisely described workflow is therefore essential.
It makes a big difference whether the object is at 0.0 (that is, mostly at the top left) or whether the center of the object is at 0.0.
Then it is important to know which objects are involved. You also need to know if the objects already exist in the file or if the script needs to create them too. If so, where did the information for creating the objects come from?
If they are already in the file, you need to know what the layer structure looks like. Is each object in its own layer, or all in one layer, or each in its own group, etc., etc.
With a meaningful sample file, the scripter or action writer can usually answer all of these questions by himself without having to ask each individual question.
That is the only background for all the annoying counter-questions. We're here to help. But reluctant for the trash can.
Copy link to clipboard
Copied
now you're talking Simon, that image is worth a lot more than the files provided...and definitely not what I had understood from your explanations.
Copy link to clipboard
Copied
here you go, select your object before running the script
// tranform selection based on csv data
// carlo canto - 05/04/2021
// https://community.adobe.com/t5/illustrator/using-spreadsheet-data-to-transform-illustrator-objects/td-p/12001685
function main() {
var idoc = app.activeDocument;
if (idoc.selection.length == 1) {
var ro = idoc.rulerOrigin;
var sel = idoc.selection[0];
idoc.rulerOrigin = [sel.position[0] + sel.width/2 + ro[0], sel.position[1] - sel.height/2 + ro[1]];
selection = null;
var csvfile = File.openDialog("Select a valid CSV file","CSV:*.csv", false);
if(csvfile != null) {
csvfile.open("r");
var csvstring = csvfile.read();
csvfile.close();
csvfile = null;
} else {
alert("Error opening CSV file.");
return;
}
var obj, delta, angle;
var rows = csvstring.split('\n');
for (var a = 1; a<rows.length; a++) {
cols = rows[a].split(',');
obj = cols[0];
delta = cols[1];
angle = cols[2];
dup = sel.duplicate();
dup.name = obj;
dup.translate(delta);
dup.rotate(angle, true,true,true,true, Transformation.DOCUMENTORIGIN);
}
idoc.rulerOrigin = ro;
}
else {
alert("select one object and try again");
}
}
main();
Copy link to clipboard
Copied
Bonjour!
Merci Carlos de m'avoir rafraichi la mémoire, Transformation.DOCUMENTORIGIN était pour moi partie dans les oubliettes.
J'admire votre générosité.
René
Ps Le poste de Simon m'a donné l'idée de faire un script à ma façon que je posterai quand il sera prêt.
Copy link to clipboard
Copied
you're welcome Rene, looking forward to seeing your script.
Copy link to clipboard
Copied
Bonjour!
Dans mon exemple, l'objet de base étant un cercle, sachant que l'aspect d'un cercle qui tourne ne change pas.
On obtient le même résultat avec un dégradé de forme comportant le même nombre d'étapes, à condition de connaître la trajectoire...
Autre exemple:
Quelle est la figure la plus réaliste ?
Si je peux libérer un peu de temps je vous fais parvenir le script avec explications.
René
Copy link to clipboard
Copied
It is a real shame that OP @Simon Templar did not provide any feedback on @CarlosCanto's goal-oriented contribution.
Copy link to clipboard
Copied
indeed, but not all is lost, the script might help future generations reading this post.
Copy link to clipboard
Copied
My favorite one is a long-time customer of mine who upon unzipping the script said the following (as copy pasted from an email dated 2016)