Skip navigation
banl_05
Currently Being Moderated

change stroke width of frames

May 9, 2012 10:06 PM

Hi Friends,

 

How to change stroke width of all frames eg:rectangle frame, ellipse frame, polygon frame.

 

 

Regards,

Balaji

 
Replies
  • Currently Being Moderated
    May 9, 2012 11:37 PM   in reply to banl_05

    var doc = app.activeDocument;

    for (var i = 0; i < doc.allPageItems.length; i++) {

        doc.allPageItems[i].strokeWeight = 1;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2012 2:01 AM   in reply to Kasyan Servetsky

    Not a good solution, Kasyan. If the stroke weight is already '1', it won't change!

     

    Use this instead:

     

    var doc = app.activeDocument;

    for (var i = 0; i < doc.allPageItems.length; i++) {

        doc.allPageItems[i].strokeWeight += 1;

    }

     

    This will change the stroke weight of all frames, as was asked.

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2012 5:36 AM   in reply to [Jongware]

    Good point, Jongware. I always have something to learn from you. Thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2012 7:45 AM   in reply to banl_05

    var doc = app.activeDocument;

    var color = doc.swatches.item("Anotada");

    for (var i = 0; i < doc.allPageItems.length; i++) {

        if (doc.allPageItems[i].strokeColor == color) {

            doc.allPageItems[i].overprintStroke = true;

            doc.allPageItems[i].strokeWeight += 1;

        }

    }

     
    |
    Mark as:
  • Currently Being Moderated
    May 11, 2012 2:38 AM   in reply to banl_05

    Let's enclose it with try-catch block:

    var doc = app.activeDocument;

    var color = doc.swatches.item("Anotada");

    for (var i = 0; i < doc.allPageItems.length; i++) {

        try {

            if (doc.allPageItems[i].strokeColor == color) {

                doc.allPageItems[i].overprintStroke = true;

                doc.allPageItems[i].strokeWeight += 1;

            }

        }

        catch(err) {

            $.writeln(err.message + ", line: " + err.line);

        }

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2012 10:25 PM   in reply to banl_05

    Hi everyone,

     

    Could someone show me how change the stroke of selected page items?

     

    Here's the code so far:

     

    var change = app.selection;

    for(var change=0;change<fx.length;change++){

         change[idt].strokeColor = "None";

         change[idt].strokeWeight = 0;

         }

     

    Many thanks and best.

     

    gr

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2012 10:28 PM   in reply to greenrookie

    sorry! should be:

     

    var change = app.selection;

    for(var idt=0;idt<change.length;idt++){

         change[idt].PageItem.strokeColor = "None";

         change[idt].PageItem.strokeWeight = 0;

         }

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 26, 2012 1:26 AM   in reply to greenrookie

    Um, why are you asking a question and then supply a script that answers it?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 26, 2012 1:35 AM   in reply to [Jongware]

    Hi, sorry, I should have mentioned before that it doesn't work!

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 26, 2012 3:52 AM   in reply to greenrookie

    Okay, it does not work. So what doesn't work?

     

    (After trying) oh, it says this

     

    Error Number: 55
    Error String: Object does not support the property or method 'PageItem'

     

    Your selection already is a page item (or it should be, when you selected just "objects"). Use this instead:

     

    var change = app.selection; 
    for(var idt=0;idt<change.length;idt++)
     {
      change[idt].strokeColor = "None";
      change[idt].strokeWeight = 0;
    }
    

     

     

    There is a slight over-kill here, because setting the stroke color to [None] will automatically set the weight to 0, but that's nothing dramatic.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 26, 2012 4:22 AM   in reply to [Jongware]

    Thanks for the reply Jongware. I tried this earlier in my futile attempts, but the stroke stayed the same on the test 'text frame'

     

    Maybe I'm saying it wrong - in terms of I would like to select text frames, graphic frames and unassigned ones and set them to "None"

     

    Do I need to target these pageItems separately?

     

    (I'm running CS5.5, OSX 10.6)

     

    Thanks again

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 4, 2012 2:04 AM   in reply to greenrookie

    Found out that removing the line;

     

    change[idt].strokeWeight = 0;

     

    will make it work properly.

     

    Many thanks again JongWare!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points