Sg2.9
Draw from txt filde - possible?
Recent RSS
Draw from txt filde - possible?
From:  tony
Date:  22. November 2010, 12:34

Hi there,

before I dive into the reference one quetions to the experts.

I´ve had several times following problem:
What I got is an excel sheet with image dimension f.e.

1.1 135x70cm
1.2 80x60,5cm
2.1 35,8x17,1cm
...

For architecture purpose I draw this sizes as rectangles in Illustrator.
The file contains over 200 items, thus not a nice job!

Is it possible to automate this with scriptographer? To Input the
meassures as txt, xml or copy and paste and let the script draw
the rectangles?

At best, it would be possible to choose a scale (f.e.: 1:100) and automatic write the
number (1.1,1.2,...) into the rectangle.

Kind regards,

Tony

Re: Draw from txt filde - possible?
From:  clankill3r
Date:  22. November 2010, 17:24

I think not, but i can be wrong.
try processing, it will be easy in that program.
And i'm sure people are whiling to help on the processing forum.

Re: Draw from txt filde - possible?
From:  Jürg Lehni
Date:  22. November 2010, 20:26

Yes, this is possible in Scriptographer. This post contains some information about how to work with files. We are planning to add a tutorial about it in the future.
Does this help?

Re: Draw from txt filde - possible?
From:  tony
Date:  22. November 2010, 22:40

Hi clankill3r,
hello Jürg,

thanks a lot for your reply.

Reading txt or xml files would be a nice gimmick but not necessary. would it be easier if I copy and paste the measures into illustrator/scriptographer? Know what I mean?

@Jürg: The File object seems to be a good direction! Great.

The night is young, time to check out the reference ;)

cheers,

tony

Re: Draw from txt filde - possible?
Date:  23. November 2010, 00:28

If the file were a text file with the contents as you describe above, the following script would be able to do it:

var pointsInCM = 28.3464567;
var line;
var file = Dialog.fileOpen('Select the txt file');
file.open();

while(line = file.readln()) {
	var matched = line.match(/^([^s]+)s([^x]+)x([^c]+)/i);
	var width = pointsInCM * matched[2].replace(/,/g, '.');
	var height = pointsInCM * matched[3].replace(/,/g, '.');
	var path = new Path.Rectangle(new Point(), new Size(width, height));
	var pointText = new PointText(path.position);
	pointText.content = matched[1];
	pointText.paragraphStyle.justification = 'center';
	var group = new Group([pointText, path]);
}
Re: Draw from txt filde - possible?
From:  tony
Date:  23. November 2010, 09:17

Jonathan – Fantastic! Thanks a million for that !

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Gearwheels 18.08.08