• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Photoshop Scripting in vb.net to change the color of an existing vector shape

New Here ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

I want to open an existing Photoshop file and select a layer called Square. There is a vector shape in this layer. I want to change the color of this vector shape. That is all.

I tried many things to approach the vector like:

test = docRef.layers("Square")
test = docRef.pathItem("Square")

All attempts failed.

I guessed it worked like a text item which I finally got to work after a full day:

  textColor = CreateObject("Photoshop.SolidColor")
        textColor.RGB.Red = 255
        textColor.RGB.Green = 0
        textColor.RGB.Blue = 0
        textItemRef.Color = textColor

This absolutely works. I don't understand how a vector shape can be so much more difficult to change.

I am not smart enough to understand Objects.Properties.Methods and such so I need a real world code example. So just referring to some guide won't help me at all. I must see working code in front of me alas. But if you can help, please do so. Without examples all code books are worthless to me.

TOPICS
Actions and scripting , Windows

Views

507

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

LATEST

try this

    Dim _appref As New Photoshop.Application
    Private Sub ChangeVColor(sender As Object, e As EventArgs) Handles Button12.Click
        ChangeShapeColor(Color.Orange)
        'or
        ChangeShapeColor("Square", Color.Blue)
    End Sub
    Private Sub ChangeShapeColor(_lyrName$, _color As Color)
        _appref.ActiveDocument.ActiveLayer = _appref.ActiveDocument.ArtLayers.Item(_lyrName$)
        ChangeShapeColor(_color)
    End Sub
    Private Sub ChangeShapeColor(_color As Color)
        If IsNothing(_appref) Then _appref = New Photoshop.Application
        If _appref.Documents.Count <= 0 Then Return

        Dim rf As New Photoshop.ActionReference
        Dim d1, d2, d3 As New Photoshop.ActionDescriptor

        rf.PutEnumerated(_appref.StringIDToTypeID("contentLayer"), &H4F72646E, &H54726774)
        d1.PutReference(1853189228, rf)
        d3.PutDouble(&H52642020, CByte(_color.R))
        d3.PutDouble(&H47726E20, CByte(_color.G))
        d3.PutDouble(&H426C2020, CByte(_color.B))
        d2.PutObject(&H436C7220, &H52474243, d3)
        d1.PutObject(&H54202020, _appref.StringIDToTypeID("solidColorLayer"), d2)
        _appref.ExecuteAction(&H73657464, d1, Photoshop.PsDialogModes.psDisplayNoDialogs)
    End Sub

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines