Sg2.9
access to selected node
Recent RSS
access to selected node
From:  mikima
Date:  8. October 2010, 18:18

is there a way to work with a selected point and not with all the path?

looking at http://www.pictrix.jp/ai/R_Corner/ seems that with illustraror scripts is possible, but i'm not able to catch what it does.

Does anybody have an hint?

Re: access to selected node
From:  mikima
Date:  13. October 2010, 16:56

Ok, found it.
It is possible to determinate if a segment is selected checking if the property point.selected is set to "true".

Re: access to selected node
Date:  14. October 2010, 11:13

Hi Mikima,

Indeed! I wrote some quick example code for others to see how to find selected segment points.

The following code draws a circle around any selected segment points:

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

for(var i = 0; i < selectedPaths.length; i++) {
	var path = selectedPaths[i];
	var segments = path.segments;
	for(var j = 0; j < segments.length; j++) {
		var segment = segments[j];
		if(segment.point.selected) {
			var circle = new Path.Circle(segment.point, 5);
			circle.fillColor = 'red';
		}
	}
}

The following code selects and deselects the segment points of selected paths in an even / odd manner:

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

for(var i = 0; i < selectedPaths.length; i++) {
	var path = selectedPaths[i];
	var segments = path.segments;
	for(var j = 0; j < segments.length; j++) {
		var selected = j.isOdd();
		var segment = segments[j];
		segment.point.selected = selected;
	}
}
Re: access to selected node
From:  mikima
Date:  15. October 2010, 15:28

thanks a lot!

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
Shape Contours V2 26.04.12