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

Centrer des cercles sur chaque angle d'un cadre en javascript

Community Beginner ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

Bonjour à tous,

Je veux positionner 4 cercles sur un rectangle de mon plan de travail. Je veux que chaque cercle coïncide avec un des angles de mon rectangle sur mon plan de travail. J'ai essayé de réaliser cette tache avec Chat GPT mais il semble oublier quelque chose...

PM

TOPICS
Draw and design , How to , Scripting , Third party plugins , Tools

Views

225

Likes

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

Guide , Jan 25, 2023 Jan 25, 2023

 

Assuming the rectangle "CONTOUR" exists:

var w = h = 10;
var paths = app.activeDocument.pathItems;
var ps = paths["CONTOUR"].pathPoints;
for (var i = 0; i < ps.length; i++) {
    paths.ellipse(ps[i].anchor[1] + h/2, ps[i].anchor[0] - w/2, w, h);
}

(First line is diameter of circles in points.)

 

Likes

Translate

Translate
LEGEND ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

And what exactly is the problem? The math? The specific script? You need to explain better. I don't even know what Chat GPT has tod o with it when you could just have drawn an example by hand.

 

Mylenium

Likes

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 Beginner ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

J'ai utilisé Chat GPT pour me générer 4 cercles et pour les positionner dans un calque.
Je veux maintenant que chacun de mes cercles soit aligné sur un des angles de mon contour qui s'appelle "CONTOUR"

polotrobo_0-1674661494639.pngpolotrobo_1-1674661527971.png

            What I have                vs             What I want




Likes

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
Guide ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

 

Assuming the rectangle "CONTOUR" exists:

var w = h = 10;
var paths = app.activeDocument.pathItems;
var ps = paths["CONTOUR"].pathPoints;
for (var i = 0; i < ps.length; i++) {
    paths.ellipse(ps[i].anchor[1] + h/2, ps[i].anchor[0] - w/2, w, h);
}

(First line is diameter of circles in points.)

 

Likes

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 Beginner ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Hi @femkeblanco Merci c'est presque parfait ! Maintenant la dernière étape consiste à ce que les cercles créés soient créés dans le calque "DECOUPE" précédement créé. J'ai essayer de trouver une solution pour déplacer les cercles dans le calque mais je n'ai pas réussi..

var newLayer = app.activeDocument.layers.add();
newLayer.name = "DECOUPE";
newLayer.move(app.activeDocument.layers["CONCEPTION - FABRICANT"], ElementPlacement.PLACEAFTER);
app.activeDocument.activeLayer = newLayer; // définir le calque "DECOUPE" comme étant le calque actif
var w = h = 10;
var paths = app.activeDocument.pathItems;
var ps = paths["CONTOUR"].pathPoints;
for (var i = 0; i < ps.length; i++) {
var newCircle = paths.ellipse(ps[i].anchor[1] + h/2, ps[i].anchor[0] - w/2, w, h);
newCircle.strokeWidth = 0.1;
newCircle.filled = false;
var cmykColor = new CMYKColor();
cmykColor.cyan = 0;
cmykColor.magenta = 100;
cmykColor.yellow = 0;
cmykColor.black = 0;
newCircle.strokeColor = cmykColor;
newCircle.name = "Cut Contour";
}

Likes

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
Advocate ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

LATEST

Bonjour!

var w = h = 10;
var cmykColor = new CMYKColor();
    cmykColor.cyan = 0;
    cmykColor.magenta = 100;
    cmykColor.yellow = 0;
    cmykColor.black = 0;

var doc = app.activeDocument;
var newLayer = doc.layers.add();
    newLayer.name = "DECOUPE";

var rect = doc.pathItems["CONTOUR"];
var ps = rect.pathPoints;

    for (var i = 0; i < ps.length; i++) {
      var newCircle = newLayer.pathItems.ellipse(ps[i].anchor[1] + h/2, ps[i].anchor[0] - w/2, w, h);
          newCircle.filled = false;
          newCircle.strokeWidth = 0.1;
          newCircle.strokeColor = cmykColor;
          newCircle.name = "Cut Contour";
    }

Likes

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