Simulate Click with Brush

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: Kukurykus, Tom, xbytor

Grrr1337
Posts: 6
Joined: Fri Nov 01, 2019 3:40 pm

Re: Simulate Click with Brush

Post by Grrr1337 »

Kukurykus wrote:
Sun Jan 03, 2021 12:55 pm
That has nothing to do with Smart Object, you simply have not unchecked 'Always Create Smart Objects When Placing' in General Preferences.

You can keep Smart Objects though if later you want to relink them to other .pngs, or simply replace embedded content.

All smart objects will refresh at once only when first they all were linked to same file, so are duplicates of each other.
Yes, that was the case and this is the behaviour what I'm after (I just didn't knew how to do it).
I've incorporated these functions to your code, so now all the imported/generated layers are smart objects linked to the corresponding image.

Code: Select all

// Edit->Preferences->General->[?] Always create smart objects when placing
// Use [Ctrl+K] to get to the preferences menu
function placeRasterSmartObjectPreference(bool)
{
  cTID = function(s) { return app.charIDToTypeID(s); };
  sTID = function(s) { return app.stringIDToTypeID(s); };
  var desc1 = new ActionDescriptor();
  var ref1 = new ActionReference();
  ref1.putProperty(cTID('Prpr'), cTID('GnrP'));
  ref1.putEnumerated(cTID('capp'), cTID('Ordn'), cTID('Trgt'));
  desc1.putReference(cTID('null'), ref1);
  var desc2 = new ActionDescriptor();
  desc2.putBoolean(sTID("placeRasterSmartObject"), bool);
  desc1.putObject(cTID('T   '), cTID('GnrP'), desc2);
  executeAction(cTID('setd'), desc1, DialogModes.NO);
}; // function placeRasterSmartObjectPreference



// Relink to File
// run with: placeRasterSmartObjectPreference(true);
function AcLyrRelinkToFile(fpath)
{
  if (app.activeDocument.activeLayer.kind != LayerKind.SMARTOBJECT) return;
  cTID = function(s) { return app.charIDToTypeID(s); };
  sTID = function(s) { return app.stringIDToTypeID(s); };
  var des = new ActionDescriptor();
  des.putPath(cTID('null'), new File(fpath));
  executeAction(sTID('placedLayerRelinkToFile'), des, DialogModes.NO);
}; // function AcLyrRelinkToFile
Kukurykus wrote:
Sun Jan 03, 2021 12:55 pm
There is event for brush clicking, but it's hidden as it generates too many lines of code.

There is workaround for it though, but better use placing method ;)
Was just curious about it, looks like theres a workaround for everything. :)

By 'placing method' I understand the technique you used in your code?
How is that done manually and how would look with using DOM?

User avatar
Kukurykus
Posts: 395
Joined: Mon Jul 25, 2016 12:36 pm

Re: Simulate Click with Brush

Post by Kukurykus »

Placing you find in File menu, by DOM you won't do it like many other commands avialable only from AM, the simpler, but slower DOM comes from.

Grrr1337
Posts: 6
Joined: Fri Nov 01, 2019 3:40 pm

Re: Simulate Click with Brush

Post by Grrr1337 »

I see that I have alot to explore,
Thanks Kukurykus your help means alot to me! :D