Stroke path problem

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

tyr

Stroke path problem

Post by tyr »

Hi everyone!

I have a script that at some point strokes a path with 1px computed brush. I create new brush with code I found on the forum:
Code: Select all   var $s = function(s) {
      return app.stringIDToTypeID(s);
   };
   var app_ref = new ActionReference;
   app_ref.putEnumerated($s('application'), $s('ordinal'), $s('targetEnum'));
   var brush_desc = (app.executeActionGet(app_ref)
      .getObjectValue($s('currentToolOptions'))
      .getObjectValue($s('brush')));
   brush_desc.putUnitDouble($s('spacing'), $s('percentUnit'), 10)
   brush_desc.putUnitDouble($s('hardness'), $s('percentUnit'), 100)
   var brush_ref = new ActionReference();
   brush_ref.putEnumerated($s('brush'), $s('ordinal'), $s('targetEnum'));
   var set_brush_desc = new ActionDescriptor();
   set_brush_desc.putReference($s('target'), brush_ref);
   set_brush_desc.putObject($s('to'), $s('brush'), brush_desc)
   executeAction($s('set'), set_brush_desc, DialogModes.NO);

   // diameter to 1
   var idsetd = charIDToTypeID("setd");
   var desc42 = new ActionDescriptor();
   var idnull = charIDToTypeID("null");
   var ref30 = new ActionReference();
   var idBrsh = charIDToTypeID("Brsh");
   var idOrdn = charIDToTypeID("Ordn");
   var idTrgt = charIDToTypeID("Trgt");
   ref30.putEnumerated(idBrsh, idOrdn, idTrgt);
   desc42.putReference(idnull, ref30);
   var idT = charIDToTypeID("T   ");
   var desc43 = new ActionDescriptor();
   var idmasterDiameter = stringIDToTypeID("masterDiameter");
   var idPxl = charIDToTypeID("#Pxl");
   desc43.putUnitDouble(idmasterDiameter, idPxl, 1.000);
   var idBrsh = charIDToTypeID("Brsh");
   desc42.putObject(idT, idBrsh, desc43);
   executeAction(idsetd, desc42, DialogModes.NO);


The problems are, however, that this new brush inherits opacity, flow settings and all the the brush controls from previously selected brush. So I'm getting strokes with different width depending on what brush was selected before. As far as I understand there's no way to clear brush controls or set the opacity/flow, does anyone maybe have some other ideas (excluding having the specific tool preset for the stroke)?

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

pfaffenbichler

Stroke path problem

Post by pfaffenbichler »

I think you can either use a Brush Preset or (if the path is really simple) try some work-around like a Layer Style or a Shape Layer’s Stroke.
tyr

Stroke path problem

Post by tyr »

Thanks pfaffenbichler,
I forgot to mention that my paths aren't connected, something like that:


So I can't use shapes
tyr

Stroke path problem

Post by tyr »

I think I got it!
'Reset Tool' command in Tool Presets resets all the opacity/flow/brush controls AND writes itself to script listener log.
So I just made a temporary tool preset, reseted it, stroked a path, deleted a preset. Thanks!
pfaffenbichler

Stroke path problem

Post by pfaffenbichler »

If the intended stroke is sharp splitting the path up and using each of its subPathItems as the Vector Mask for a Shape Layer might be an option.
http://ps-scripts.com/bb/viewtopic.php?f=9&t=5677? ... ade36391a5
tyr

Stroke path problem

Post by tyr »

Wow, thanks pfaffenbichler, that is even better!