forked from lohriialo/photoshop-scripting-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkLayer.py
29 lines (22 loc) · 823 Bytes
/
LinkLayer.py
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
# This scripts demonstrates how to link two layers.
from win32com.client import Dispatch, GetActiveObject, GetObject
# Start up Photoshop application
# Or get Reference to already running Photoshop application instance
# app = Dispatch('Photoshop.Application')
app = GetActiveObject("Photoshop.Application")
# PS constants, see psCC2018.py
psPixels = 1
psNewRGB = 2
psWhite = 1
strtRulerUnits = app.Preferences.RulerUnits
if len(app.Documents) < 1:
if strtRulerUnits is not psPixels:
app.Preferences.RulerUnits = psPixels
docRef = app.Documents.Add(320, 240, 72, None, psNewRGB, psWhite)
else:
docRef = app.ActiveDocument
layerRef = docRef.ArtLayers.Add()
layerRef2 = docRef.ArtLayers.Add()
layerRef.Link(layerRef2)
# Set the ruler back to where it was
app.Preferences.RulerUnits = strtRulerUnits