Skip to main content
Legend
April 26, 2020
Answered

Creating preset from action descriptor

  • April 26, 2020
  • 3 replies
  • 3790 views

Is there a way to create a preset not based on ActionReference (r1), but directly from ActionDescriptor of tool settings (t)? essentially they refer to the same object, just in different ways...

 

var d = new ActionDescriptor();
	var r = new ActionReference();
	var r1 = new ActionReference();

	r.putClass( s2t( "toolPreset" ));
	d.putReference( c2t( "null" ), r );
	r1.putProperty( s2t( "property" ), s2t( "currentToolOptions" ));
	r1.putEnumerated( s2t( "application" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	d.putReference( s2t( "using" ), r1 );
	d.putString( s2t( "name" ), 'test name' );
	executeAction( s2t( "make" ), d, DialogModes.NO );

 

 

r = new ActionReference()
        r.putProperty(s2t('property'), s2t('tool'))
        r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'))
		t = executeActionGet(r).getObjectValue(s2t('currentToolOptions'))

 

This topic has been closed for replies.
Correct answer r-bin
I seem to understand what you wanted.
 
I think without choosing a tool, i.e. without using "currentToolOptions", nothing will work.
I didn’t succeed.
 

3 replies

r-binCorrect answer
Legend
April 27, 2020
I seem to understand what you wanted.
 
I think without choosing a tool, i.e. without using "currentToolOptions", nothing will work.
I didn’t succeed.
 
Kukurykus
Legend
May 27, 2020

Maybe you have a workaround how for this: BUG: New Tool Preset item is greyed for 9 tools

 

For ex. Note Tool is very alike to Count Tool, but for some reason we can't create new preset for that 2nd.

Legend
April 26, 2020
It’s not at all clear what you want.
What is the app.addEventListener function?

Why do you need to create presets?

Do you know about
app.saveToolBrushToFile ()
app.applyToolBrushFromFile ()
?
Will they help you?
 
jazz-yAuthor
Legend
April 26, 2020
app.notifiers.add () , sorry thought about something else and wrote it 🙂
 
I would like the user to be able to use the latest states of the tool without making any special efforts to save them. Tool parameters can simply be stored in a variable without writting to a file, but then you need to provide control of these variables from a script - I don’t see the point in this approach, since all the necessary tools for this are already in Photoshop (presets).
Legend
April 26, 2020
The descriptor can be saved to a file and read it from there to perform certain actions.
Anyway, nothing is clear.
Describe the complete algorithm for your intended actions.
 
JJMack
Community Expert
Community Expert
April 26, 2020

I don't know why you would want to do that.  How did you set the current tool and its current settings in your script  to begin with. If you could do that in you script why would you need to make it a named preset.  I have seen scripts the set the current tool and select a tool preset or load a set of tool presets.  I have never seen a script or action that creates a named tool preset.   I would also think your script should check to see if a preset by that name already exist not keep adding duplicate named presets.

JJMack
jazz-yAuthor
Legend
April 26, 2020

In a certain situation i want to be able to  save in preset previous brush and tool settings (which were before the activation of the new preset). To do this, I get the CurrentToolOptions through events at the time of drawing on the canvas and store that descriptor until a new preset is selected on the panel.

JJMack
Community Expert
Community Expert
April 26, 2020

I still do not understand how the script will know which of the descriptors you have stored to use to able to set current tool and its setting so you can create a new current tool preset and name it uniquely.  The action manager code you poste seems to be for the a "toolPreset" for the "currentToolOptions".

 

JJMack