Copy link to clipboard
Copied
Hi,
I'm trying to automate moving a path's starting anchor point by a predeterminate step.
However, apparently I can't reference an array in the .setEntirePath() method.
Is this true ou did I blunder?
Thanks in advance.
var MSG_noobjects = "Please select some objects.";
var MSG_nodocs = "You have no open document."var error=0;
if (documents.length<1) {error++;
alert(MSG_nodocs);
}if (error == 0) {
var theObjects=selection;
if (theObjects.length<1 && error == 0) {error++;
alert(MSG_noobjects);
}}
if (error < 1) {
changePathStarts(theObjects);
}function changePathStarts(theItems) {
for (var i = 0; i < theItems.length; i++) {
if (theItems.typename == "PathItem" && !theItems.locked && !theItems.parent.locked && !theItems.layer.locked) {pathLen = theItems.pathPoints.length;
var pointsarr = new Array();
for (k = 0; k < pathLen; k++) {//fill array with path's pointspointsarr.push(theItems.pathPoints[k]);
}pointsarr.push(pointsarr.shift()); //array rotate/shift register right
var newpath = app.activeDocument.pathItems.add();
newpath.setEntirePath(Arraypointsarr);
app.redraw();
}}
}
I was trying to change a path starting point to another in the same path.
Something like this:
Finally I did it:
.../**
* Created by Kaiserin on 19/01/2018.
*/
var MSG_noobjects = "Please select some objects.";
var MSG_nodocs = "You have no open document."
var error=0;
if (documents.length<1) {error++;
alert(MSG_nodocs);
}if (error == 0) {
var theObjects=selection;
if (theObjects.length<1 && error == 0) {error++;
alert(MSG_noobjects);
}}
if (error < 1) {
changePathStarts(theObjects);
}functio
Copy link to clipboard
Copied
not sure what you are trying to do but I did notice this.
ln44: newpath.setEntirePath(Arraypointsarr);
"Arraypointsarr" is undefined....should just be "pointsarr"
Also line 36 should probably be...pointsarr.push(theItems.pathPoints
the dot anchor is where you get the actual position of the point.
Copy link to clipboard
Copied
I was trying to change a path starting point to another in the same path.
Something like this:
Finally I did it:
/**
* Created by Kaiserin on 19/01/2018.
*/
var MSG_noobjects = "Please select some objects.";
var MSG_nodocs = "You have no open document."
var error=0;
if (documents.length<1) {error++;
alert(MSG_nodocs);
}if (error == 0) {
var theObjects=selection;
if (theObjects.length<1 && error == 0) {error++;
alert(MSG_noobjects);
}}
if (error < 1) {
changePathStarts(theObjects);
}function changePathStarts(theItems) {
for (var i = 0; i < theItems.length; i++) {
if (theItems.typename == "GroupItem") {//ungroups before processing
for (var ix = 0; ix < theItems.length; ix++) {var item = theItems[ix];
var itemType = item.constructor.name;
if (itemType != "Group") {continue;
}item.ungroup();
}changePathStarts(theItems.pathItems);
}if (theItems.typename == "PathItem" && !theItems.locked && !theItems.parent.locked && !theItems.layer.locked) {
pathLen = theItems.pathPoints.length;
var pointsarr = new Array();
for (k = 0; k < pathLen; k++) {//fill array with path's points
pointsarr.push(theItems.pathPoints);
}pointsarr.push(pointsarr.shift()); //array rotate/shift register right
var newpath = app.activeDocument.pathItems.add()for (k = 0; k < pointsarr.length; k++) {
var newPoint = newpath.pathPoints.add();
newPoint.anchor = pointsarr.anchor;
newPoint.leftDirection = pointsarr.leftDirection;
newPoint.rightDirection = pointsarr.rightDirection;
newPoint.pointType = pointsarr.pointType;
}newpath.closed = true;
}}
}
for (var k = 0; k < theObjects.length; k++) {
theObjects
.remove();
}app.redraw();