Help! I need to automate creating Illustrator Print Templates

Community Beginner ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Hello Community!

I need to create many temlates I have a spreadsheet with "Item Size" and "Imprint Area". Is there a way with Scipts or Actions I can import that data to create 2 Artboards to the data size? I have attached an image for reference.  I have 5300 items to do this for, so you obviusly any help is more than appreciated! 

 

Screen%20Shot%202021-03-10%20at%202.34.25%20PM

TOPICS
How to, Import and export, Scripting

Views

211

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Adobe Community Professional , Mar 11, 2021 Mar 11, 2021
You can try this! It's not very optimized and I did it super quick, but it can be improved to make the process a lot faster by not creating a new document every time but re-adjusting the existing doc and saving it in a different place. #target illustrator function test () { var csv = File.openDialog("Choose CSV", "*.csv"); var contents; if (csv) { csv.open("r"); contents = csv.read().split(/[\r\n]/g); csv.close(); } else { return; } var outputFolder = Folder(csv.path + "/output"); ...

Likes

Translate

Translate
Adobe Community Professional , Mar 11, 2021 Mar 11, 2021
Oh , duh I forgot the CSV file! Here is what it is supposed to look like. ItemSizeImprintArea400x400500x500250x200300x275250x125300x325450x275500x40075x25200x150 So that 'x' is used inside a cell to hold 2 values and it is used as the splitter. Yea, that code was never going to work without this additional piece of info!

Likes

Translate

Translate
Adobe Community Professional ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Are you looking to add 5300 documents or 10600 artboards?
The artboards in a single document are up to 1000.

But other than that, of course this is easily done with scripting but your instructions can be taken many different ways.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

I have 5300 products i am creating templates for. For each product I am looking to have 1 document created, inside the document are 2 artboards. One represents the "item Size" and the other represents "imprint area". Does that help?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

You can try this!

It's not very optimized and I did it super quick, but it can be improved to make the process a lot faster by not creating a new document every time but re-adjusting the existing doc and saving it in a different place.

#target illustrator
function test () {
	var csv = File.openDialog("Choose CSV", "*.csv");
	var contents;
	if (csv) {
		csv.open("r");
		contents = csv.read().split(/[\r\n]/g);
		csv.close();
	} else {
		return;
	}
	var outputFolder = Folder(csv.path + "/output");
	var coordRecords = [];
	var thisRecord;
	var col1Split, col2Split;
	var col1x, col1y, col2x, col2y;
	for (var i = 1; i < contents.length; i++) {
		thisRecord = contents[i].split(",");
		col1Split = thisRecord[0].split("x");
		col2Split = thisRecord[1].split("x");
		col1x = col1Split[0] * 1;
		col1y = col1Split[1] * 1;
		col2x = col2Split[0] * 1;
		col2y = col2Split[1] * 1;
		coordRecords.push({
			itemSize : [col1x, col1y],
			imprintArea : [col2x, col2y],
		});
	}

	var coordRecord;
	var newDoc;
	var startingArtboardCoords;
	var newBoard, newArtboardRect;
	for (var i = 0; i < coordRecords.length; i++) {
		coordRecord = coordRecords[i];
		/** @TyPe {Document} */
		newDoc = app.documents.add();
		startingArtboardCoords = newDoc.artboards[0].artboardRect;
		newDoc.artboards[0].name = "Imprint Size";
		newDoc.artboards[0].artboardRect = [
			startingArtboardCoords[0],
			startingArtboardCoords[1],
			coordRecords[i].itemSize[0],
			coordRecords[i].itemSize[1]
		];
		newArtboardRect = [
			startingArtboardCoords[0] + coordRecords[i].itemSize[0] + 50,
			startingArtboardCoords[1],
			coordRecords[i].itemSize[0] + coordRecords[i].imprintArea[0] + 50,
			coordRecords[i].imprintArea[1],
		];
		newBoard = newDoc.artboards.add(newArtboardRect);
		newBoard.name = "Imprint Area";
		newDoc.saveAs(File(outputFolder + "/Doc-" + (i + 1) + ".ai"));
		newDoc.close();
	}
};
test();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

I would love to try it! I appreaciate your help. Now how do I use this?

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

You save this text as .jsx file and go to Illustrator File > Scripts > Other scripts. You can do other more advanced things later to minimize this process, but it looks like this is something you won't be using that often (?).
So when you run it thus, it will go!

However just like with Excel macros, if you are at a scripting stage of asking 'how do I use this', make sure to be careful about not running random scripts from untrusted sources as they can wreak havoc on your computer just like an Excel Macro can - that's why they make it so you can't even send xlms books over gmail and such.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Yes I understand and appreicate your forwarning. I looked through the help you have provided to others and feel that you have good intentions. I did save the copy and save the code as plain text in Textedit. I saved it as .jsx to my destop and and tried to run the script in a new document.  See the error attached,

 

Screen Shot 2021-03-11 at 8.55.31 AM.png

Screen Shot 2021-03-11 at 8.55.14 AM.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Oh , duh I forgot the CSV file! Here is what it is supposed to look like.

ItemSize ImprintArea
400x400 500x500
250x200 300x275
250x125 300x325
450x275 500x400
75x25 200x150

 

So that 'x' is used inside a cell to hold 2 values and it is used as the splitter. Yea, that code was never going to work without this additional piece of info!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Awesome! Got it, I love this community! This will help for sure.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

One more thing, it appears its the size is in Points. How do I use inches instread as that is the measuments I have to work with?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

LATEST

You can actually make it work without any edits to the script! Simply make your formula in Excel take your inch values and multiply them by 72 to get the point values that are workable in the script.
Else we'd have to edit the script by multiplying things by 72 inside there for internal use.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines