Hi, pixxxel schubser that's fantastic, thank you so much.
Apologies for the missing answers, the Illustrator version is CC, and the data is coming from an excel document that i am populating from internal data.
Just one last question, could each box now be filled with a different colour ? your original example showed the path being filled with Red, but ifi wanted to fill each rectangle with a different colour, is this possible ?
Many thanks,
Ouch!
There are so much ways to do this. But You need many "secure question" in the script - e.g. it is dependent of color mode, or swatches exists, or the installed language of Illustrator and so on …
Here is one "simple way" to work with three additional RGB color values columns in your txt file. Be sure that the color mode of your document is RGB.
// rectangleDraw_dataFromTxt.jsx
// regards pixxxelschubser
var aDoc = app.activeDocument;
var mm = 2.8346456;
// required: tab separated txt and opened RGB document in Illustrator (CS5+)
// see https://forums.adobe.com/message/7934424#7934424
// top left width height R G B
// 20 20 100 100 255 0 0
var aFile = File ("~/Desktop/Testdateien/topleftwidthheight.txt");
aFile.open("r");
var txtFile = aFile.read();
aFile.close();
var theText = txtFile.split("\n");
var T, rect, col;
var col = new RGBColor();
for (i=0; i<theText.length-1; i++) {
T=theText.split( "\t");
$.writeln(T[4]);
rect = aDoc.pathItems.rectangle( -(T[0] * mm), T[1] * mm, T[2] * mm, T[3] * mm );
col.red = T[4];
col.green = T[5];
col.blue = T[6];
rect.fillColor = col;
}
Have fun
