Sg2.9
How to add existing scripts?
Recent RSS
How to add existing scripts?
From:  Filip Pomykalo
Date:  28. February 2012, 15:37

Dear Scriptographer team,

I am trying to use an existing script I have downloaded which calculates the area of the object (http://www.IllustrationETC.com/AIbuds/JET_GetInfoScripts.zip) and I put the .js file in the Scriptographer Scripts folder but it doesn't work, instead it says this:

“TypeError: Cannot read property "length" from undefined
at Scriptographer Scripts/JET_GetArea.js:1”

Could you please take a look at it and tell me how to fix the problem. This is the code of the script.

if ( app.documents.length > 0 && app.activeDocument.selection.length > 0 ) {
var docRef=app.activeDocument;
var pathRef=docRef.selection[0];
var pathRefArea=pathRef.area;

alert ("Square Points: "+Math.round(pathRefArea*100)/100+"\n"
+"Square Picas: "+(Math.round((pathRefArea/144)*100))/100+"\n"
+"Square Inches: "+(Math.round((pathRefArea/5184)*100))/100+"\n"
+"Square Millimeters: "+(Math.round((pathRefArea/8.037)*100))/100+"\n"
+"Square Centimeters: "+(Math.round((pathRefArea/803.520)*100))/100);
}

Thank you in advance, kind regards,
Filip Pomykalo

Re: How to add existing scripts?
Date:  28. February 2012, 16:38

That script is intended for the ESTK which is not compatible with Scriptographer. Although what you're after is rather easy to do with Scriptographer. Try this out instead:

var selectedItems = document.selectedItems

for(i = 0; i < selectedItems.length; i++){
	var a = selectedItems[i].area
	print('Object ' + (i + 1))
	print('Square Points: ' + (Math.round(a * 100) / 100))
	print('Square Picas: ' + (Math.round((a / 144) * 100) / 100))
	print('Square Inches: ' + (Math.round((a / 5184) * 100) / 100))
	print('Square Millimeters: ' + (Math.round((a / 8.037) * 100) / 100))
	print('Square Centimeters: ' + (Math.round((a / 803.520) * 100)) / 100 + 'n')
}

Good luck!

Re: How to add existing scripts?
From:  Filip Pomykalo
Date:  28. February 2012, 17:08

Thank you very much Håkan, it works perfectly! =)

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
RandomTools 21.08.08