-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathGuides.py
More file actions
26 lines (22 loc) · 735 Bytes
/
Copy pathGuides.py
File metadata and controls
26 lines (22 loc) · 735 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
# Add ruler guides (macOS).
# Uses do_javascript for reliable cross-version guide creation.
from appscript import k
from ps_connect import close_all_documents, photoshop
ps = photoshop()
close_all_documents(ps)
ps.settings.ruler_units.set(k.pixel_units)
doc = ps.make(
new=k.document,
with_properties={k.width: 600, k.height: 400, k.resolution: 72, k.name: "Guides"},
)
# Native appscript guide keywords vary by Photoshop version; JSX is stable.
jsx = """
var d = app.activeDocument;
d.guides.add(Direction.VERTICAL, 100);
d.guides.add(Direction.VERTICAL, 500);
d.guides.add(Direction.HORIZONTAL, 50);
d.guides.add(Direction.HORIZONTAL, 350);
d.guides.length;
"""
count = ps.do_javascript(jsx)
print("Guide count:", count)