• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
4

Help for script anchors point

Explorer ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

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)
}
TOPICS
Feature request , How-to , Performance , Scripting , SDK

Views

181

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 26, 2023 Nov 26, 2023

change the top parameter from - to +

 

from this

var rect = group.pathItems.rectangle(pos[1] - 5, pos[0] - 5, 10, 10); // Adjust the size and position as needed

 

to this

var rect = group.pathItems.rectangle(pos[1] + 5, pos[0] - 5, 10, 10); // Adjust the size and position as needed

Votes

Translate

Translate
Adobe
Guide ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

What do you want the script to do?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

change the top parameter from - to +

 

from this

var rect = group.pathItems.rectangle(pos[1] - 5, pos[0] - 5, 10, 10); // Adjust the size and position as needed

 

to this

var rect = group.pathItems.rectangle(pos[1] + 5, pos[0] - 5, 10, 10); // Adjust the size and position as needed

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

LATEST

Wow this is amazing thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines