Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Illustrator Scripting (javascripting) Mural Artboard Automation Script Help

Community Beginner ,
Apr 01, 2025 Apr 01, 2025
I was working with ChatGPT to Write a Script for Illustrator to Layout and arrange the artboards for Large Murals. Based on the provided info (max Printer Width, Mural Overall Size, Scale 1:1, 1:4, 1:2, 1:10, Overlap width for panels, Custom Bleed for each side, in addition to the overall size,  it should set and arrange all the equal width tiled artboards to print the mural in the current document. I have attached an .ai example file for a 180x120 Mural as to how the blank file should look, as well as a Mural calculator spreadsheet, Its exported to eXCEL, so it may not work as nicely as my Numbers Spreadsheet. It seems to have lost some of the formatting, but the calculations seem to work. I am very novice at scripting. Any guiadance how to get this to work would be appreciated. Seems like I can't attach an .ai file so i saved as (ai editable) .pdf, please download and open it in Illustrator to see the example Illustrator File.
 
The script runs all the prompts, Creates the overall dimension artboard, and then fails with this error: Error adding artboard: an Illustrator error occurred: 1346458189 ('MRAP'). Seems like when it tries to create the individual panel artboards. Maybe it doesn't like them overlapping.

How can I fix this see the Script below.

TIA

 

#target illustrator

function main() {

// Prompt for overall mural dimensions

var muralWidth = prompt("Enter the overall width of the mural (in inches):", "96");

var muralHeight = prompt("Enter the overall height of the mural (in inches):", "48");

// Prompt for scale

var scale = prompt("Choose scale (1:1, 1:2, 1:4, 1:10):", "1:1");

var scaleFactor = 1;

if (scale === "1:2") {

scaleFactor = 2;

} else if (scale === "1:4") {

scaleFactor = 4;

} else if (scale === "1:10") {

scaleFactor = 10;

}

muralWidth = parseFloat(muralWidth) * scaleFactor;

muralHeight = parseFloat(muralHeight) * scaleFactor;

// Maximum printable width and height

var maxPanelWidth = prompt("Enter the maximum individual artboard panel width (in inches):", "24");

maxPanelWidth = parseFloat(maxPanelWidth) * scaleFactor;

var maxPanelHeight = 1800; // Set maximum panel height based on printer specifications

// Prompt for bleed sizes

var bleedTop = prompt("Enter the bleed size for the top (in inches):", "0.25");

var bleedBottom = prompt("Enter the bleed size for the bottom (in inches):", "0.25");

var bleedLeft = prompt("Enter the bleed size for the left (in inches):", "0.25");

var bleedRight = prompt("Enter the bleed size for the right (in inches):", "0.25");

bleedTop = parseFloat(bleedTop) * scaleFactor;

bleedBottom = parseFloat(bleedBottom) * scaleFactor;

bleedLeft = parseFloat(bleedLeft) * scaleFactor;

bleedRight = parseFloat(bleedRight) * scaleFactor;

// Prompt for panel overlaps

var overlapSize = prompt("Enter the panel overlap size (in inches):", "0.5");

overlapSize = parseFloat(overlapSize) * scaleFactor;

// Calculate effective mural dimensions including bleed

var effectiveWidth = muralWidth - (bleedLeft + bleedRight);

var effectiveHeight = muralHeight - (bleedTop + bleedBottom);

// Determine the number of panels needed in width and height

var numPanelsX = Math.ceil(effectiveWidth / (maxPanelWidth - overlapSize));

var numPanelsY = Math.ceil(effectiveHeight / (maxPanelHeight - overlapSize));

// Create document

var doc = app.documents.add(DocumentColorSpace.RGB, muralWidth, muralHeight);

// Create Artboards

for (var y = 0; y < numPanelsY; y++) {

for (var x = 0; x < numPanelsX; x++) {

var xPos = (maxPanelWidth * x) - (overlapSize * x);

var yPos = (maxPanelHeight * y) - (overlapSize * y);

// Create artboard rectangle considering bleed

var artboardRect = [

xPos + bleedLeft,

muralHeight - (yPos + maxPanelHeight + bleedBottom), // Adjust for Y axis

xPos + maxPanelWidth + bleedLeft,

muralHeight - yPos // Adjust to get the proper top Y coordinate

];

if (artboardRect[1] < 0) { // Prevent negative Y coordinate

artboardRect[1] = 0;

}

// Attempt to add artboard, ensure successful addition with try-catch

try {

// Add artboard to the document.

doc.artboards.add(artboardRect);

} catch (e) {

alert("Error adding artboard: " + e.message);

}

}

}

alert("Artboards for the mural setup have been created!");

}

// Run the script

main();

TOPICS
Scripting
663
Translate
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 1 Correct answer

Enthusiast , Apr 01, 2025 Apr 01, 2025

Try to change artboard height to negative height value:

var artboardRect = [
  xPos + bleedLeft,
  muralHeight - (yPos + maxPanelHeight + bleedBottom),
  xPos + maxPanelWidth + bleedLeft,
  (muralHeight - yPos) * -1 // This fix
];

 

Translate
Adobe
Enthusiast ,
Apr 01, 2025 Apr 01, 2025

Try to change artboard height to negative height value:

var artboardRect = [
  xPos + bleedLeft,
  muralHeight - (yPos + maxPanelHeight + bleedBottom),
  xPos + maxPanelWidth + bleedLeft,
  (muralHeight - yPos) * -1 // This fix
];

 

Translate
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 ,
Apr 03, 2025 Apr 03, 2025
LATEST

Thank You for your response. that worked.

Tts laying out the  panels but its building them in points not inches.

How do I add the syntax for "RulerUnits.Inches" so it does all the calculations in inches?

 

TIA

asvbrian

Translate
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
Advocate ,
Apr 01, 2025 Apr 01, 2025

Bonjour,

il existe un moyen simple de constituer une grille.

Après avoir calculé les valeurs utiles, ce qui n'est pas le plus difficile.

Voir exemple de script.

var maxPanelHeight =  1440,  // in pt
    maxPanelWidth = 1728,
    numPanelsX = 7,
    numPanelsY = 6,
    bleedBottom = bleedLeft = 28.35,  // -10
    nbArtBoard = numPanelsX*numPanelsY;


var docRef = app.documents.add(DocumentColorSpace.RGB,
                  maxPanelWidth, maxPanelHeight, nbArtBoard,
                  DocumentArtboardLayout.GridByRow,
                  bleedLeft,
                  numPanelsX
                  );

René

 

Translate
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