Thanks, I tried it, but I can't see anything result.
It works for me, you must have incorrectly copied/pasted.
Here it is on a platter:
// create separations for four point paths;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
var thePathIndex = selectedPath2020 ();
if (thePathIndex != -1) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var thePath = collectPathInfoFromDesc2020 (activeDocument, thePathIndex);
// if path has one subpathitem and four points;
if (thePath.length == 1 && thePath[0].length == 6) {
////////////////////////////////////
// Original input
var sep1input = prompt("Enter the number across:", 3);
// Remove anything that is not a digit or full point
var sep1inputCleaner = sep1input.replace(/[^\d\.]/, '');
// Convert to integer
var sep1toDigit = parseInt(sep1inputCleaner, 10);
// Final result
var sep1 = sep1toDigit;
// Original input
var sep2input = prompt("Enter the number down:", 7);
// Remove anything that is not a digit or full point
var sep2inputCleaner = sep2input.replace(/[^\d\.]/, '');
// Convert to integer
var sep2toDigit = parseInt(sep2inputCleaner, 10);
// Final result
var sep2 = sep2toDigit;
////////////////////////////////////
var point1 = thePath[0][0][0];
var point2 = thePath[0][1][0];
var point3 = thePath[0][2][0];
var point4 = thePath[0][3][0];
var theArray2 = new Array;
theArray2.push(thePath[0]);
////////////////////////////////////
var theDistH1 = (point2[0]-point1[0])/(sep1+1);
var theDistV1 = (point2[1]-point1[1])/(sep1+1);
var theDistH2 = (point4[0]-point3[0])/(sep1+1);
var theDistV2 = (point4[1]-point3[1])/(sep1+1);
for (var m = 1; m <= sep1; m++) {
var point1a = [point1[0]+m*theDistH1, point1[1]+m*theDistV1];
var point2a = [point4[0]-m*theDistH2, point4[1]-m*theDistV2];
theArray2.push([[point1a, point1a, point1a, false], [point2a, point2a, point2a, false], false, 1807])
};
////////////////////////////////////
var theDistH1 = (point3[0]-point2[0])/(sep2+1);
var theDistV1 = (point3[1]-point2[1])/(sep2+1);
var theDistH2 = (point1[0]-point4[0])/(sep2+1);
var theDistV2 = (point1[1]-point4[1])/(sep2+1);
for (var m = 1; m <= sep2; m++) {
var point1a = [point2[0]+m*theDistH1, point2[1]+m*theDistV1];
var point2a = [point1[0]-m*theDistH2, point1[1]-m*theDistV2];
theArray2.push([[point1a, point1a, point1a, false], [point2a, point2a, point2a, false], false, 1807])
};
////////////////////////////////////
var thePath = createPath2018(theArray2, Math.random());
app.preferences.rulerUnits = originalRulerUnits;
strokeLayer (String(sep1+"x"+sep2));
thePath.remove();
}
};
};
////// collect path info from actiondescriptor, smooth added //////
function collectPathInfoFromDesc2020 (myDocument, thePath) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// based of functions from xbytor’s stdlib;
var ref = new ActionReference();
ref.putIndex(cTID("Path"), thePath+1);
/*for (var l = 0; l < myDocument.pathItems.length; l++) {
var thisPath = myDocument.pathItems[l];
if (thisPath == thePath && thisPath.kind == PathKind.WORKPATH) {
ref.putProperty(cTID("Path"), cTID("WrPt"));
};
if (thisPath == thePath && thisPath.kind != PathKind.WORKPATH && thisPath.kind != PathKind.VECTORMASK) {
ref.putIndex(cTID("Path"), l + 1);
};
if (thisPath == thePath && thisPath.kind == PathKind.VECTORMASK) {
var idPath = charIDToTypeID( "Path" );
var idPath = charIDToTypeID( "Path" );
var idvectorMask = stringIDToTypeID( "vectorMask" );
ref.putEnumerated( idPath, idPath, idvectorMask );
};
};*/
var desc = app.executeActionGet(ref);
var pname = desc.getString(cTID('PthN'));
// create new array;
var theArray = new Array;
var pathComponents = desc.getObjectValue(cTID("PthC")).getList(sTID('pathComponents'));
// for subpathitems;
for (var m = 0; m < pathComponents.count; m++) {
var listKey = pathComponents.getObjectValue(m).getList(sTID("subpathListKey"));
var operation1 = pathComponents.getObjectValue(m).getEnumerationValue(sTID("shapeOperation"));
switch (operation1) {
case 1097098272:
var operation = 1097098272 //cTID('Add ');
break;
case 1398961266:
var operation = 1398961266 //cTID('Sbtr');
break;
case 1231975538:
var operation = 1231975538 //cTID('Intr');
break;
default:
// case 1102:
var operation = sTID('xor') //ShapeOperation.SHAPEXOR;
break;
};
// for subpathitem’s count;
for (var n = 0; n < listKey.count; n++) {
theArray.push(new Array);
var points = listKey.getObjectValue(n).getList(sTID('points'));
try {var closed = listKey.getObjectValue(n).getBoolean(sTID("closedSubpath"))}
catch (e) {var closed = false};
// for subpathitem’s segment’s number of points;
for (var o = 0; o < points.count; o++) {
var anchorObj = points.getObjectValue(o).getObjectValue(sTID("anchor"));
var anchor = [anchorObj.getUnitDoubleValue(sTID('horizontal')), anchorObj.getUnitDoubleValue(sTID('vertical'))];
var thisPoint = [anchor];
try {
var left = points.getObjectValue(o).getObjectValue(cTID("Fwd "));
var leftDirection = [left.getUnitDoubleValue(sTID('horizontal')), left.getUnitDoubleValue(sTID('vertical'))];
thisPoint.push(leftDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var right = points.getObjectValue(o).getObjectValue(cTID("Bwd "));
var rightDirection = [right.getUnitDoubleValue(sTID('horizontal')), right.getUnitDoubleValue(sTID('vertical'))];
thisPoint.push(rightDirection)
}
catch (e) {
thisPoint.push(anchor)
};
try {
var smoothOr = points.getObjectValue(o).getBoolean(cTID("Smoo"));
thisPoint.push(smoothOr)
}
catch (e) {thisPoint.push(false)};
theArray[theArray.length - 1].push(thisPoint);
};
theArray[theArray.length - 1].push(closed);
theArray[theArray.length - 1].push(operation);
};
};
// by xbytor, thanks to him;
function cTID (s) { return cTID[s] || cTID[s] = app.charIDToTypeID(s); };
function sTID (s) { return sTID[s] || sTID[s] = app.stringIDToTypeID(s); };
// reset;
app.preferences.rulerUnits = originalRulerUnits;
return theArray;
};
////// create a path from collectPathInfoFromDesc2012-array //////
function createPath2018(theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// thanks to xbytor;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Path'), cTID('WrPt'));
desc1.putReference(sTID('null'), ref1);
var list1 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var thisSubPath = theArray[m];
var desc2 = new ActionDescriptor();
desc2.putEnumerated(sTID('shapeOperation'), sTID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
var list2 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('Clsp'), thisSubPath[thisSubPath.length - 2]);
var list3 = new ActionList();
for (var n = 0; n < thisSubPath.length - 2; n++) {
var thisPoint = thisSubPath[n];
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[0][0]);
desc5.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[0][1]);
desc4.putObject(cTID('Anch'), cTID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[1][0]);
desc6.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[1][1]);
desc4.putObject(cTID('Fwd '), cTID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[2][0]);
desc7.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[2][1]);
desc4.putObject(cTID('Bwd '), cTID('Pnt '), desc7);
desc4.putBoolean(cTID('Smoo'), thisPoint[3]);
list3.putObject(cTID('Pthp'), desc4);
};
desc3.putList(cTID('Pts '), list3);
list2.putObject(cTID('Sbpl'), desc3);
desc2.putList(cTID('SbpL'), list2);
list1.putObject(cTID('PaCm'), desc2);
};
desc1.putList(cTID('T '), list1);
executeAction(cTID('setd'), desc1, DialogModes.NO);
// name work path;
var desc30 = new ActionDescriptor();
var ref6 = new ActionReference();
var idPath = charIDToTypeID( "Path" );
ref6.putClass( idPath );
desc30.putReference( charIDToTypeID( "null" ), ref6 );
var ref7 = new ActionReference();
ref7.putProperty( idPath, charIDToTypeID( "WrPt" ) );
desc30.putReference( charIDToTypeID( "From" ), ref7 );
desc30.putString( charIDToTypeID( "Nm " ), thePathsName );
executeAction( charIDToTypeID( "Mk " ), desc30, DialogModes.NO );
/// get index;
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("itemIndex"));
ref.putEnumerated( charIDToTypeID("Path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var pathDesc = executeActionGet(ref);
var myPathItem = activeDocument.pathItems[pathDesc.getInteger(stringIDToTypeID("itemIndex")) - 1];
app.preferences.rulerUnits = originalRulerUnits;
return myPathItem
};
////// determine selected path, updated 09.2015 //////
function selectedPath2020 () {
try {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID("property"), stringIDToTypeID("targetPathIndex"));
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var docDesc = executeActionGet(ref);
return docDesc.getInteger(stringIDToTypeID("targetPathIndex"));
return app.activeDocument.pathItems[docDesc.getInteger(stringIDToTypeID("targetPathIndex"))]
}
catch (e) {return undefined}
};
////// shape layer //////
function strokeLayer (theName) {
// =======================================================
var idnull = stringIDToTypeID( "null" );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
var idRGBColor = stringIDToTypeID( "RGBColor" );
var idred = stringIDToTypeID( "red" );
var idgrain = stringIDToTypeID( "grain" );
var idblue = stringIDToTypeID( "blue" );
var idcolor = stringIDToTypeID( "color" );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
////////////////////////////////////
var desc11 = new ActionDescriptor();
var ref4 = new ActionReference();
ref4.putClass( idcontentLayer );
desc11.putReference( idnull, ref4 );
var desc12 = new ActionDescriptor();
var desc13 = new ActionDescriptor();
var desc14 = new ActionDescriptor();
desc14.putDouble( idred, 255 );
desc14.putDouble( idgrain, 255 );
desc14.putDouble( idblue, 255 );
desc13.putObject( idcolor, idRGBColor, desc14 );
////////////////////////////////////
var desc15 = new ActionDescriptor();
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc15.putInteger( idstrokeStyleVersion, 2 );
var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
desc15.putBoolean( idstrokeEnabled, true );
var idfillEnabled = stringIDToTypeID( "fillEnabled" );
desc15.putBoolean( idfillEnabled, false );
var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc15.putUnitDouble( idstrokeStyleLineWidth, idpixelsUnit, 3.000000 );
var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
var idpointsUnit = stringIDToTypeID( "pointsUnit" );
desc15.putUnitDouble( idstrokeStyleLineDashOffset, idpointsUnit, 0.000000 );
var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
desc15.putDouble( idstrokeStyleMiterLimit, 100.000000 );
var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
var idstrokeStyleRoundCap = stringIDToTypeID( "strokeStyleRoundCap" );
desc15.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleRoundCap );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );
desc15.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleAlignCenter = stringIDToTypeID( "strokeStyleAlignCenter" );
desc15.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignCenter );
var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );
desc15.putBoolean( idstrokeStyleScaleLock, false );
var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );
desc15.putBoolean( idstrokeStyleStrokeAdjust, false );
var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );
var list1 = new ActionList();
desc15.putList( idstrokeStyleLineDashSet, list1 );
var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );
var idblendMode = stringIDToTypeID( "blendMode" );
var idnormal = stringIDToTypeID( "normal" );
desc15.putEnumerated( idstrokeStyleBlendMode, idblendMode, idnormal );
var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );
var idpercentUnit = stringIDToTypeID( "percentUnit" );
desc15.putUnitDouble( idstrokeStyleOpacity, idpercentUnit, 100.000000 );
var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
var desc16 = new ActionDescriptor();
var desc17 = new ActionDescriptor();
desc17.putDouble( idred, 0.000000 );
desc17.putDouble( idgrain, 0.000000 );
desc17.putDouble( idblue, 0.000000 );
desc16.putObject( idcolor, idRGBColor, desc17 );
desc15.putObject( idstrokeStyleContent, idsolidColorLayer, desc16 );
var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );
desc15.putDouble( idstrokeStyleResolution, 72.000000 );
desc12.putObject( idstrokeStyle, idstrokeStyle, desc15 );
////////////////////////////////////
desc12.putString( stringIDToTypeID( "name" ), theName );
desc12.putObject( stringIDToTypeID( "type" ), idsolidColorLayer, desc13 );
desc11.putObject( stringIDToTypeID( "using" ), idcontentLayer, desc12 );
executeAction( stringIDToTypeID( "make" ), desc11, DialogModes.NO );
};