File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ function explodeLayer ( layers ) {
2+
3+ // Check if multiple layers selected
4+ if ( layers . length > 1 ) {
5+ alert ( "Select a single shape layer" ) ;
6+ return ;
7+ }
8+
9+ // Get the selected layer
10+ var layer = layers [ 0 ] ;
11+
12+ // Check if the layer is null or wrong type
13+ if ( layer == undefined || layer . matchName !== 'ADBE Vector Layer' ) {
14+ alert ( "Select a shape layer" ) ;
15+ return ;
16+ }
17+
18+ // Get the elements of the original shape layer
19+ var contents = layer . property ( "Contents" ) ;
20+
21+ // Browse through contents array
22+ for ( var i = 1 ; i <= contents . numProperties ; i ++ ) {
23+
24+ // Get the original property
25+ var o_prop = contents . property ( i ) ;
26+
27+ // Skip the property if not enabled
28+ if ( o_prop . enabled ) {
29+
30+ // Duplicate the original layer and rename with property name
31+ var n_layer = layer . duplicate ( ) ;
32+ n_layer . name = o_prop . name ;
33+
34+ // Get the elements of the new layer
35+ var n_layerContents = n_layer . property ( "Contents" ) ;
36+
37+ // Remove all properties different from current original property
38+ for ( var k = n_layerContents . numProperties ; k > 0 ; k -- ) {
39+
40+ var n_prop = n_layerContents . property ( k ) ;
41+
42+ if ( i === k )
43+ continue ;
44+ else
45+ n_prop . remove ( ) ;
46+
47+ }
48+
49+ }
50+
51+ }
52+
53+ }
54+
55+
56+ explodeLayer ( app . project . activeItem . selectedLayers ) ;
You can’t perform that action at this time.
0 commit comments