Photoshop Script similar to Illustrator Blend Tool for Paths?


hello,

 

for learning purposes create intersection path(s) between subpaths of mainpath using extendscript.

screenshot.png

i guess have find difference of each points' coordinates , draw new line using these information. (actually more better if has step options in illustrator blend tool.) since beginner (learning scripting) got confused arrays. being array inside array.

 

i tried 2 ways, none of them completed. since there no point number subpaths array should inside loops suppose

 

please help;

here hopeless tryout...

 

#target photoshop app.bringtofront(); displaydialogs = dialogmodes.no; // don't display dialog   if(documents.length==0){    alert("please open document , add path in order run script") }else{    var doc = app.activedocument; if (doc.pathitems.length == 0) {alert ('please add 1 path');} else {              if (doc.pathitems[0].name == "work path") {         // convert work path path         doc.pathitems[0].name = "path"         } targetpath = doc.pathitems.getbyname('path'); var subpathscount = targetpath.subpathitems.length; // count of subpaths   // first path function extractsubpathinfo1(pathobj){       var patharray1 = new array();     var pl2 = pathobj.subpathitems.length;       for(var s1=0;s1<pl1;s1++){           var parray = new array();             for(var i1=0;i1<pathobj.subpathitems[0].pathpoints.length;i1++){                parray1[i1] = new pathpointinfo;                parray1[i1].kind = pathobj.subpathitems[0].pathpoints[i1].kind;                parray1[i1].anchor = pathobj.subpathitems[0].pathpoints[i1].anchor;                parray1[i1].leftdirection = pathobj.subpathitems[0].pathpoints[i1].leftdirection;                parray1[i1].rightdirection = pathobj.subpathitems[0].pathpoints[i1].rightdirection;             };           patharray1[patharray.length] = new array();           patharray1[patharray.length - 1] = new subpathinfo();           patharray1[patharray.length - 1].operation = pathobj.subpathitems[0].operation;           patharray1[patharray.length - 1].closed = pathobj.subpathitems[0].closed;           patharray1[patharray.length - 1].entiresubpath = parray1;       };       return patharray1;   };   // second path function extractsubpathinfo2(pathobj){       var patharray2 = new array();     var pl2 = pathobj.subpathitems.length;       for(var s2=0;s2<pl2;s2++){           var parray2 = new array();             for(var i2=0;i2<pathobj.subpathitems[1].pathpoints.length;i2++){                parray2[i2] = new pathpointinfo;                parray2[i2].kind = pathobj.subpathitems[1].pathpoints[i2].kind;                parray2[i2].anchor = pathobj.subpathitems[1].pathpoints[i2].anchor;                parray2[i2].leftdirection = pathobj.subpathitems[1].pathpoints[i2].leftdirection;                parray2[i2].rightdirection = pathobj.subpathitems[1].pathpoints[i2].rightdirection;             };           patharray2[patharray2.length] = new array();           patharray2[patharray2.length - 1] = new subpathinfo();           patharray2[patharray2.length - 1].operation = pathobj.subpathitems[1].operation;           patharray2[patharray2.length - 1].closed = pathobj.subpathitems[1].closed;           patharray2[patharray2.length - 1].entiresubpath = parray2;       };       return patharray2;   };  firstpathpointcount = targetpath.subpathitems[0].pathpoints.length; secondpathpointcount= targetpath.subpathitems[1].pathpoints.length; var firstpathrightdirectionarray= new array(); var firstpathleftdirectionarray = new array();  var a0xy =  new array(); var a0x =  new array(); var a0y =  new array();  var a1xy =  new array(); var a1x =  new array(); var a1y =  new array();  var a2xy =  new array(); var a2x =  new array(); var a2y =  new array();  a0xy.push(targetpath.subpathitems[0].pathpoints[0].leftdirection); a0x=  a0xy[0].tostring().split(",")[0]; a0y=  a0xy[0].tostring().split(",")[1];  a1xy.push(targetpath.subpathitems[0].pathpoints[1].leftdirection); a1x=  a0xy[0].tostring().split(",")[0]; a1y=  a0xy[0].tostring().split(",")[1];  a2xy.push(targetpath.subpathitems[0].pathpoints[2].leftdirection); a2x=  a0xy[0].tostring().split(",")[0]; a2y=  a0xy[0].tostring().split(",")[1];  var b0xy =  new array(); var b0x =  new array(); var b0y =  new array();  var b1xy =  new array(); var b1x =  new array(); var b1y =  new array();  var b2xy =  new array(); var b2x =  new array(); var b2y =  new array();  b0xy.push(targetpath.subpathitems[1].pathpoints[0].leftdirection); b0x=  b0xy[0].tostring().split(",")[0]; b0y=  b0xy[0].tostring().split(",")[1];  b1xy.push(targetpath.subpathitems[1].pathpoints[1].leftdirection); b1x=  b1xy[0].tostring().split(",")[0]; b1y=  b1xy[0].tostring().split(",")[1];  b2xy.push(targetpath.subpathitems[1].pathpoints[2].leftdirection); b2x=  b2xy[0].tostring().split(",")[0]; b2y=  b2xy[0].tostring().split(",")[1];  alert (b0x - a0x); 

 

 

 

 

 

 

 

}

}

scripting paths if ps bit of pain. final result want creating these blended paths in ps. might easier use ia , import them ps. playing around paths in ia , ps. wanted scripting of shapes in ps, ability script paths way wanted difficult or didn't work. ended creating paths in ia, converting paths coordinates xml file redrew in ps shape layers apply color based on reference layer in ps.



More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Why is os_ViewContainer running?

Animate - problem with duplicating scripts after loop