Answered
Help for script anchors point
please who can help me to make this path created to come with position center of anchors point ?
main();
function main() {
var doc = app.activeDocument;
// Create a new group at the beginning of each script run
var newGroup = doc.groupItems.add();
newGroup.name = "Artwork Group " + (doc.groupItems.length); // Give a unique name to the group
// Pass the new group to the handlePaths function
handlePaths(doc.selection, newGroup);
}
// Modify handlePaths to accept the new group as a parameter
function handlePaths(sel, group) {
for (var i = 0; i < sel.length; i++) {
var item = sel[i];
if (item.typename == "PathItem") {
artworkOnPoints(item, group);
} else if (item.typename == "GroupItem") {
// Recursively handle items within the group
handlePaths(item.pageItems, group);
} else if (item.typename == "CompoundPathItem") {
// Recursively handle items within the compound path
handlePaths(item.pathItems, group);
}
// Continue to check for other types if needed
}
}
// Modify artworkOnPoints to accept the new group as a parameter
function artworkOnPoints(path, group) {
var pts = path.pathPoints;
for (var i = 0; i < pts.length; i++) {
var pos = pts[i].anchor;
// Create a rectangle at the specified anchor point
createRectangleAtPoint(pos, group);
}
}
// Create a rectangle at the specified position and add it to the group
function createRectangleAtPoint(pos, group) {
var rect = group.pathItems.rectangle(pos[1] - 5, pos[0] - 5, 10, 10); // Adjust the size and position as needed
// Customize the rectangle's appearance here (e.g., fill color, stroke)
}
