Skip to main content
Known Participant
April 28, 2021
Question

Using Spreadsheet Data to transform Illustrator objects

  • April 28, 2021
  • 16 replies
  • 7051 views

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!

This topic has been closed for replies.

16 replies

pixxxelschubser
Community Expert
Community Expert
May 9, 2021

It is a real shame that OP @Simon Templar did not provide any feedback on @CarlosCanto's goal-oriented contribution.

CarlosCanto
Community Expert
Community Expert
May 10, 2021

indeed, but not all is lost, the script might help future generations reading this post.

CarlosCanto
Community Expert
Community Expert
May 5, 2021

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();
renél80416020
Inspiring
May 11, 2021

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.

 

 

CarlosCanto
Community Expert
Community Expert
May 12, 2021

you're welcome Rene, looking forward to seeing your script.

CarlosCanto
Community Expert
Community Expert
May 4, 2021

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.

 

pixxxelschubser
Community Expert
Community Expert
May 4, 2021

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.

Known Participant
May 4, 2021

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.

Known Participant
May 4, 2021

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.

pixxxelschubser
Community Expert
Community Expert
May 4, 2021

Okay, here's the .csv. Thanks again CarlosCanto.


By @Simon Templar

                                                                                            --> jump to quoted post

 

This could be a possible result of your CSV data (Untitled spreadsheet - Sheet1.csv).

 

assumed:

26 simple rectangles with

top left on 0,0

 

each of them:

moved in 1.1 steps from 0,0 and

rotated in 15° steps

renél80416020
Inspiring
May 4, 2021

Bonjour Simon,

Si à 40 ans vous n'êtes pas capable d'illustrer votre demande, c'est de la mauvaise volonté...

Par exemple ? (appliqué à un même objet dupliqué à chaque étape)

René

 

 

pixxxelschubser
Community Expert
Community Expert
May 4, 2021

 

many of us know how to write scripts, but probably many of us have not had a chance to write the script for you. You're not a programmer, I can't simply give you direction and expect you to follow, it takes time to learn, it takes time to write scripts once you know how to write scripts.

 

as for providing more information as pixxxel has requested, he's right, it's not nearly enough. I'm writing a script as proof of concept, it might not be what you have in mind, but I guess you don't have any files to work with as of now.


By @CarlosCanto

 

 

Did I already mention that I like you?

😉

CarlosCanto
Community Expert
Community Expert
May 5, 2021
quoteDid I already mention that I like you?

😉


By @pixxxelschubser

 

I'm not sure 🙂

Kurt Gold
Community Expert
Community Expert
May 4, 2021

Simon,

 

basically your request may be pretty clear, but please understand: Script developers or action makers do know that there may be countless unknown conditions.

 

They prefer to know all of them before working out possible solutions.