Copy link to clipboard
Copied
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();
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
];
Copy link to clipboard
Copied
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
];
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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é
Find more inspiration, events, and resources on the new Adobe Community
Explore Now