Code: Select all
from PSPApp import *
def ScriptProperties():
return {
'Author': u'Ken Arway',
'Copyright': u'2013',
'Description': u'Copies all visible layers to a newly created ra'\
u'ster layer.',
'Host': u'PaintShop Pro',
'Host Version': u'15.00'
}
def Do(Environment):
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((15,0,0),1)
}
})
# CopyMerged
App.Do( Environment, 'CopyMerged', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((15,0,0),1)
}
})
# New Raster Layer
App.Do( Environment, 'NewRasterLayer', {
'General': {
'Opacity': 100,
'Name': u'Copy Merged 1',
'IsVisible': True,
'IsTransparencyLocked': False,
'LinkSet': 0,
'UseHighlight': False,
'PaletteHighlightColor': (255,255,64),
'GroupLink': True,
'BlendMode': App.Constants.BlendMode.Normal
},
'BlendRanges': {
'BlendRangeGreen': (0,0,255,255,0,0,255,255),
'BlendRangeRed': (0,0,255,255,0,0,255,255),
'BlendRangeBlue': (0,0,255,255,0,0,255,255),
'BlendRangeGrey': (0,0,255,255,0,0,255,255)
},
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((15,0,0),1)
}
})
# SelectAll
App.Do( Environment, 'SelectAll', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((15,0,0),1)
}
})
# PasteIntoSelection
App.Do( Environment, 'PasteIntoSelection', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((15,0,0),1)
}
})
# SelectNone
App.Do( Environment, 'SelectNone', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((15,0,0),1)
}
})
As the name implies, all the visible layers will be copied and merged, so it's easy to first "hide" the layers you don't want merged before running the script.
Yes, it's just a series of recorded actions; but the key is its use of the "Select All" and "Paste Into Selection" actions -- that ensures that the resulting merged layer maintains the same positioning as the individual layers. In other words, if your original layers have a transparent background and opaque areas that are off-center, simply using Edit...Paste As New Layer will center those opaque areas in the canvas, which is not what you want....
Enjoy!
