2 Replies Latest reply on Jun 28, 2017 9:45 AM by jajohns8

    changing strokecolor of many paths without looping

    jajohns8

      Hello,

      I have an SVG file that has quite a few objects on it. I need to change all the stroke color to grey and the strokewidth to .2.

      When I attempt to use a loop, the process works, but it takes 9 minutes to process a file. I have to do it faster.

       

      //this shows construct for updating color with a loop.

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

      pathArt = doc.pathItems[i];

      pathArt.strokeColor = myNewColor;

      }

       

       

      Another post about a similar situation recommended using the approach of selecting items with executeMenuCommand and then changing the default fill color.

      [Scripting] I need to implement a script to change 100,000 pathItems color in 1 time

       

      I have the following script which selects all items, but does not actually change the default fill color or the stroke weight.:

       

      app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

      var doc = app.activeDocument;

       

      //doc.DefaultStrokeColor = makeColor(153,153,153);

      app.executeMenuCommand("selectall");

       

       

      doc.DefaultStrokeColor = makeColor(153,153,153);

      doc.DefaultStrokeWidth = .2;

       

      function makeColor(r,g,b){

          var c = new RGBColor();

          c.red   = r;

          c.green = g;

          c.blue  = b;

          return c;

          }

       

      How can I perform the change of stroke color and stroke weight without a loop?

      Thanks so much for your time.