-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathLayerSetGroup.py
More file actions
32 lines (26 loc) · 944 Bytes
/
Copy pathLayerSetGroup.py
File metadata and controls
32 lines (26 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
from pathlib import Path
_ROOT = Path(__file__).resolve().parents[2]
if str(_ROOT) not in sys.path:
sys.path.insert(0, str(_ROOT))
from photoshop_scripting import require_windows_com
require_windows_com()
# LayerSets.Add — create a layer group (folder).
from photoshop_scripting import DocumentFill, DocumentMode, Units, get_app, saved_preferences
app = get_app()
with saved_preferences(app, units=Units.PIXELS):
doc = app.Documents.Add(
400, 300, 72, "LayerSet Demo", int(DocumentMode.RGB), int(DocumentFill.WHITE)
)
layer = doc.ArtLayers.Add()
layer.Name = "Grouped layer"
group = doc.LayerSets.Add()
group.Name = "My Group"
try:
layer.Move(group, 2)
except Exception:
try:
layer.MoveToEnd(group)
except Exception as exc:
print("Created group; move API note:", exc)
print("Layer sets:", doc.LayerSets.Count, "—", group.Name)