Skip to main content
Participant
February 22, 2008
Question

VB: Simple Selection

  • February 22, 2008
  • 1 reply
  • 542 views
Hi all,
I am just writing my first Photoshop CS2 script in VB that exports all layers to separate files, where the resulting file resolutions are the same as the layer bounds.
So far no problem.
The way I thought about is
- Opening Document
- running on all Layers
- making a Selection of Layer-Size
- Copy this Selection
- New File, paste, Save
- next Layer

I'm sticking in making a selection. Didn't manage to build the correct syntax for selecting the layer bounds I got by layer.Bounds.

The current code is:
document.Selection.Select(layer.Bounds, Photoshop.PsSelectionType.psReplaceSelection, 0, False)

Unfortunately this throws an error. What am I doing wrong?
This topic has been closed for replies.

1 reply

Participant
February 22, 2008
Finally directly after writing this thread I found it ;)

Dim x1 As Integer = layer.Bounds(0)
Dim y1 As Integer = layer.Bounds(1)
Dim x2 As Integer = layer.Bounds(2)
Dim y2 As Integer = layer.Bounds(3)

'Dim selectionBounds(,) As Integer = New Integer(3, 1) {{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}}
Dim selectionBounds() As Object = New Object() {New Object() {x1, y1}, New Object() {x2, y1}, New Object() {x2, y2}, New Object() {x1, y2}}

document.Selection.Select(selectionBounds, Photoshop.PsSelectionType.psReplaceSelection, 0, False)