Sg2.9
Selected anchorpoint's coords
Recent RSS
Selected anchorpoint's coords
From:  Derek S.
Date:  28. May 2012, 21:37

I'd like to select a single anchor point,
and then have a script retrieve its coordinates.
Is this possible with Scriptographer?

Here is a regular javascript example
that adds an octagon to the selected anchor point.

var aDoc = app.activeDocument;
var sPath = aDoc.pathItems[0];
var sel = sPath.selectedPathPoints;
for (i=0; i<sel.length; i++) {
var pp = sel[i];
if (pp.selected == PathPointSelection.ANCHORPOINT)
var aOctagon = aDoc.pathItems.polygon(pp.anchor[0], pp.anchor[1], 15, 8)
}

Thanks!

Re: Selected anchorpoint's coords
Date:  4. June 2012, 18:26

Here you go:

var selectedItems = document.getItems({
	type: Path,
	selected: true
});

if (selectedItems.length) {
	for (var i = 0; i < selectedItems.length; i++) {
		var path = selectedItems[i];
		for (var j = 0; j < path.segments.length; j++) {
			var segment = path.segments[j];
			if (segment.point.selected) {
				// Do something with the segment point:
				var circle = new Path.Circle(segment.point, 5);
				circle.fillColor = 'red';
			}
		}
	}
}
Re: Selected anchorpoint's coords
From:  Derek S.
Date:  4. June 2012, 23:32

Thank you! I appreciate the example.

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
objects on paths (scatter brush) 29.07.12