-
Notifications
You must be signed in to change notification settings - Fork 92
/
FillSelection.py
34 lines (27 loc) · 1.05 KB
/
FillSelection.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
30
31
32
33
34
# Fill the current selection with an RGB color.
from win32com.client import Dispatch, GetActiveObject, GetObject
# Start up Photoshop application
# Or get Reference to already running Photoshop application instance
# app = win32com.client.Dispatch('Photoshop.Application')
app = GetActiveObject("Photoshop.Application")
# PS constants, see psCC2018.py
psPixels = 1
psNewRGB = 2
psWhite = 1
psNormalBlendColor = 2
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)
docRef.ArtLayers.Add()
app.Preferences.RulerUnits = strtRulerUnits
if app.ActiveDocument.ActiveLayer.IsBackgroundLayer == False:
selRef = app.ActiveDocument.Selection
fillcolor = Dispatch("Photoshop.SolidColor")
fillcolor.RGB.Red = 225
fillcolor.RGB.Green = 0
fillcolor.RGB.Blue = 0
selRef.Fill(fillcolor, psNormalBlendColor, 25, False)
else:
print("Can't perform operation on background layer")