Skip to main content
Participant
July 22, 2018
Answered

How I can get last Index of gradient in list of gradients ?

  • July 22, 2018
  • 1 reply
  • 720 views

I created .jsx file from action and have a line with text :

ref1.putIndex(cTID('Grdn'), 1);


but

ref1.putIndex(cTID('Grdn'), -1);


in

  function step1(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putIndex(cTID('Grdn'), -1);

    desc1.putReference(cTID('null'), ref1);

    executeAction(sTID('delete'), desc1, dialogMode);

  };

don't work for last gradients in list, I try to created action with 3 steps:
1)create new gradient
2)delete this gradient
3)delete last gradient -1
I converted this action in jsx file and try to run, but this script didn't work without edits.
If you have any ideas - thank you.

This topic has been closed for replies.
Correct answer Kukurykus

function sTT(v) {return stringIDToTypeID(v)}

(ref = new ActionReference()).putProperty(sTT('property'), pM = sTT('presetManager'))

ref.putEnumerated(sTT('application'), sTT('ordinal'), sTT('tergetEnum'))

cnt = executeActionGet(ref).getList(pM).getObjectValue(2).getList(sTT('name')).count;

(ref = new ActionReference()).putIndex(sTT('gradientClassEvent'), cnt);

(dsc = new ActionDescriptor()).putReference(sTT('null'), ref)

executeAction(sTT('delete'), dsc)

1 reply

Kukurykus
KukurykusCorrect answer
Legend
July 22, 2018

function sTT(v) {return stringIDToTypeID(v)}

(ref = new ActionReference()).putProperty(sTT('property'), pM = sTT('presetManager'))

ref.putEnumerated(sTT('application'), sTT('ordinal'), sTT('tergetEnum'))

cnt = executeActionGet(ref).getList(pM).getObjectValue(2).getList(sTT('name')).count;

(ref = new ActionReference()).putIndex(sTT('gradientClassEvent'), cnt);

(dsc = new ActionDescriptor()).putReference(sTT('null'), ref)

executeAction(sTT('delete'), dsc)

Participant
July 22, 2018

Thanks!, it works.