Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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