forked from lohriialo/photoshop-scripting-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeSelection.py
23 lines (20 loc) · 942 Bytes
/
MakeSelection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Get the active document and make a new selection.
from comtypes.client import GetActiveObject, CreateObject
# Start up Photoshop application
# Or get Reference to already running Photoshop application instance
# app = Dispatch('Photoshop.Application')
app = GetActiveObject("Photoshop.Application")
# create new document if no document is opened
if len([(i, x) for i, x in enumerate(app.Documents, 1)]) < 1:
psPixels = 1
strtRulerUnits = app.Preferences.RulerUnits
app.Preferences.RulerUnits = psPixels
psNewRGB = 2 # from enum PsNewDocumentMode
psWhite = 1 # from enum PsDocumentFill
docRef = app.Documents.Add(320, 240, 72, None, psNewRGB, psWhite)
app.preferences.rulerUnits = strtRulerUnits
else:
docRef = app.ActiveDocument
sel_area = ((50, 60), (150, 60), (150, 120), (50, 120))
psReplaceSelection = 1 # from enum PsSelectionType
docRef.Selection.Select(sel_area, psReplaceSelection, 5.5, False)