put gradient on many symbols on 1 layer. pathItems question

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

tyr

put gradient on many symbols on 1 layer. pathItems question

Post by tyr »

Hey everyone,
I have an image atlas with tons of symbols on one layer and I need to apply a gradient to every single one of them.
My first idea was to load a selection from transparency and convert it to path, and then somehow make an gradient layer for every subpath. And I thought I'd simply write something like
Code: Select allvar newPathItem = activeDocument.pathItems.add("name"+i , activeDocument.pathItems[0].oldPathSubitem)
but I guess new path can't use existing path's entireSubPath property.
Gladly will hear any suggestions!

tyr

put gradient on many symbols on 1 layer. pathItems question

Post by tyr »

Here's my current script, but it doesn't work, something is wrong with 2nd argument of add pathItems

Code: Select allworkPath = activeDocument.pathItems[0];

for (i = 0; i < workPath.subPathItems.length; i++) {
   var lineArray = new Array()
   for (k = 0; k < workPath.subPathItems.pathPoints.length; k++) {
      lineArray[k] = new PathPointInfo
      lineArray[k].kind = PointKind.CORNERPOINT
      lineArray[k].anchor = workPath.subPathItems.pathPoints[k].anchor
      lineArray[k].leftDirection = workPath.subPathItems.pathPoints[k].anchor;
      lineArray[k].rightDirection = workPath.subPathItems.pathPoints[k].anchor;
   }

   lineSubPathArray = new SubPathInfo();
   lineSubPathArray.operation = ShapeOperation.SHAPEXOR
   lineSubPathArray.closed = true
   lineSubPathArray.entireSubPath = lineArray;
   
   var myPathItem = activeDocument.pathItems.add("name", lineSubPathArray)
}
tyr

put gradient on many symbols on 1 layer. pathItems question

Post by tyr »

actually I got it working, sorry for posting in a hurry!

lineSubPathArray should has been an array