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

Create frame in Illustrator with js

Participant ,
Feb 22, 2024 Feb 22, 2024

Hi,

 

I need to create rectangular frame with 0.5 pt stroke with CMYK value of 0, 0, 0 , 100 and with overprint on specific layer.

 

Here what I have figured out so far, maybe:

 

var myDoc = app.activeDocument;

var myLayer = myDoc.layers.add();
myLayer.name = "GUIDES";

myCardWidth = myDoc.width;
myCardHeight = myDoc.height;

myTrimLine = myLayer.pathItems.rectangle.add();

myTrimLine.geometricBounds = (0, 0, myCardWidth, myCardHeight);

myTrimLine.filled = false;
myTrimLine.stroked = true;

myDoc.strokeWidth = 0.5 pt;

 

myDoc.documentColorSpace.CMYK

var newCMYKColor = new cmykColor();
newCMYKColor.black = 100;
newCMYKColor.cyan = 0;
newCMYKColor.magenta = 0;
newCMYKColor.yellow = 0;

 

Thank you for your help.

Yulia

 

 

TOPICS
Scripting
301
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

Community Expert , Feb 22, 2024 Feb 22, 2024

Hi @Yuliascript, you are on the right track! Here's a version that does each of things you want. Please look through each part and compare to your script and see what I've done differently.

- Mark

 

/**
 * @author m1b
 * @discussion https://community.adobe.com/t5/illustrator-discussions/create-frame-in-illustrator-with-js/m-p/14441605
 */
(function () {

    var myDoc = app.activeDocument;

    // get (or make) the layer
    var myLayer,
        layerName = "GUIDES";
    try {
        myLayer = 
...
Translate
Adobe
Community Expert ,
Feb 22, 2024 Feb 22, 2024

Hi @Yuliascript, you are on the right track! Here's a version that does each of things you want. Please look through each part and compare to your script and see what I've done differently.

- Mark

 

/**
 * @author m1b
 * @discussion https://community.adobe.com/t5/illustrator-discussions/create-frame-in-illustrator-with-js/m-p/14441605
 */
(function () {

    var myDoc = app.activeDocument;

    // get (or make) the layer
    var myLayer,
        layerName = "GUIDES";
    try {
        myLayer = myDoc.layers.getByName(layerName);
    } catch (error) {
        myLayer = myDoc.layers.add();
        myLayer.name = layerName;
    }

    // make the black color
    var myBlack = new CMYKColor();
    myBlack.black = 100;
    myBlack.cyan = 0;
    myBlack.magenta = 0;
    myBlack.yellow = 0;

    // make a rectangle the size of the first artboard
    var bounds = myDoc.artboards[0].artboardRect;
    var myTrimLine = myLayer.pathItems.rectangle(bounds[1], bounds[0], bounds[2] - bounds[0], -(bounds[3] - bounds[1])); // TLWH

    // set the rectangle's properties
    myTrimLine.filled = false;
    myTrimLine.stroked = true;
    myTrimLine.strokeWidth = 0.5;
    myTrimLine.strokeColor = myBlack;
    myTrimLine.strokeOverprint = true;

})();

 

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
Participant ,
Feb 23, 2024 Feb 23, 2024
LATEST

Thank you, Mark. It works perfectly!

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