Measuring the area of an artwork
Copy link to clipboard
Copied
For the purposes of silk screen printing, I would separate the artwork into individual layers based on color, convert all colors to black, and print each layer separately. In order to estimate the ink consumption, I'd like to determine the 'area' of black ink on each layer, sum them up, and compare the total ink usage to another artwork to identify which one requires more ink. This information is crucial for cost estimation purposes. Is there a method for determining the black ink area on each layer?
Explore related tutorials & articles
Copy link to clipboard
Copied
The total area of a fill color could be obtained with a script, but this will not include strokes.
Copy link to clipboard
Copied
Thanks for the reply. That will do, since artworks for silkscreen do not use strokes. How is the script done?
Copy link to clipboard
Copied
I tried this script below but it wouldn't work:
// Adobe Illustrator script to calculate total area of a fill color in a PDF file
// Function to calculate the area of a path item
function calculateArea(pathItem) {
var area = 0;
// Check if the pathItem has a fill color
if (pathItem.filled) {
// Get the color of the fill
var fillColor = pathItem.fillColor;
// Check if the fill color is a solid color
if (fillColor instanceof RGBColor) {
// Calculate the area of the pathItem
area += pathItem.area;
}
}
return area;
}
// Main function to calculate total area
function calculateTotalArea() {
var doc = app.activeDocument;
var totalArea = 0;
// Loop through all page items in the document
for (var i = 0; i < doc.pageItems.length; i++) {
var currentItem = doc.pageItems[i];
totalArea += calculateArea(currentItem);
}
// Display the total area
alert("Total Fill Color Area: " + totalArea.toFixed(2) + " square units");
}
// Run the main function
calculateTotalArea();
Copy link to clipboard
Copied
Thank you for the tip! This script below worked.
function calculateArea(pathItem) {
var area = 0;
// Check if the pathItem has a fill color
if (pathItem.filled) {
// Get the color of the fill
var fillColor = pathItem.fillColor;
// Check if the fill color is a solid color
if (fillColor instanceof RGBColor || fillColor instanceof CMYKColor || fillColor instanceof GrayColor) {
// Calculate the area of the pathItem
area += pathItem.area;
}
}
return area;
}
function calculateTotalArea() {
var doc = app.activeDocument;
var totalArea = 0;
// Loop through all page items in the document
for (var i = 0; i < doc.pageItems.length; i++) {
var currentItem = doc.pageItems[i];
totalArea += calculateArea(currentItem);
}
// Display the total area
alert("Total Fill Color Area: " + totalArea.toFixed(2) + " square units");
}
calculateTotalArea();

