Skip to main content
femkeblanco
Legend
March 19, 2020
質問

Is there a way, through scripting, to translate (move) anchors and handles?

  • March 19, 2020
  • 返信数 1.
  • 505 ビュー

The pathItem method translate(dx, dy) moves paths. Is there anything similar to move anchors and/or handles? After a quick google search, I suspect there isn't, but I would appretiate if someone can confirm this. Thanks in advance. 

 

 

このトピックへの返信は締め切られました。

返信数 1

pixxxelschubser
Community Expert
Community Expert
March 19, 2020

Hi @femkeblanco,

do you mean something like that?

 

// anchorpoint move - and handles
// regards pixxxel_schubser

var aDoc = app.documents.add();
var Rect = aDoc.pathItems.rectangle(100, 100, 400, 400, false);
Rect.stroked = true;
Rect.filled = false;
redraw();
alert("Rectangle created");

Rect.pathPoints[0].anchor = Array(0,20);
redraw();
alert ("Point moved");

Rect.pathPoints[0].leftDirection = Array(300,300);
Rect.pathPoints[0].rightDirection = Array(0,200);
redraw();
alert("Handles changed");

Rect.selected = true;
redraw();

 

 

If so, have fun

😉

femkeblanco
femkeblanco作成者
Legend
March 20, 2020

Thank you very much for your reply. 

 

I was thinking of moving the position (x, y) without knowing the position, by specifying the change (dx, dy).  Of course, I can add (dx, dy) to the position,

 

var Rect = activeDocument.pathItems.rectangle(100, 100, 400, 400, false);
var dx = -300; var dy = 320;
redraw();
alert("Rectangle created");

Rect.pathPoints[0].anchor = [300 + dx, -300 + dy];
redraw();
alert ("Point moved");

 

but then I would have to have known the position. 

 

So I don't think that, for example, I can move the lower left anchor by 100 points downwards without knowing its position, can I? 

 

On a separate, but related subject, I can't move selected points, can I?  So I don't think that, for example, I can select the lower left anchor (either manually or through scripting) and assign it a new (x, y) position, can I? 

 

Again, thank you very much for your reply.