This is not be fully tested but seems to work with my limited number of actionSets.
Code: Select allgetSelectedAction()
function getSelectedAction(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Actn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var selectedName = desc.getString(charIDToTypeID("Nm "));
var selectedIndex = desc.getInteger(charIDToTypeID("ItmI"));
var parentName = desc.getString(charIDToTypeID("PrNm"));
var parentIndex = desc.getInteger(charIDToTypeID("PrIn"));
if(isActionSet( parentIndex, parentName )){
var setName = parentName;
var actionName = selectedName;
}else{
var setName = findAction(parentIndex, parentName );
var actionName = parentName;
}
return [setName,actionName];
};
function isActionSet( parentIndex, parentName ){
var res = false;
try{
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "ASet" ), parentIndex );
var setName = executeActionGet( ref ).getString(charIDToTypeID("Nm "));
if(setName == parentName) res = true;
}catch(e){}
return res;
};
function findAction(parentIndex, parentName ) {
var i = 1;
var found = false;
while (!found) {
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), i);
var desc;
try {
desc = executeActionGet(ref);
} catch (e) {
break;
} finally {
}
if (desc.hasKey(charIDToTypeID('Nm '))) { ;
var setName = desc.getString(charIDToTypeID('Nm '));
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('Actn'), parentIndex);
ref.putIndex(charIDToTypeID('ASet'), i);
try{
var adesc = executeActionGet(ref);
var actName = adesc.getString(charIDToTypeID('Nm '));
if(actName==parentName) return setName;
}catch(e){}
}
i++;
}
};
How do you know what action selected in the panel Аct
-
stat
How do you know what action selected in the panel Аct
YEEESSS!!!
Superrrr!
Thank you very much.
Tell me please, why this code not work?
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("ASet"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var selectedName = desc.getString(charIDToTypeID("Nm "));
I want to print the name of the selected ActionSet
Superrrr!
Thank you very much.
Tell me please, why this code not work?
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("ASet"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var selectedName = desc.getString(charIDToTypeID("Nm "));
I want to print the name of the selected ActionSet
-
Mike Hale
How do you know what action selected in the panel Аct
This is just a guess but I think it is because an action set can never be the target of an executeAction. Unlike layerSets, there is nothing you can do to an action set that is recordable where the set is the target. Deleting an action set is logged by scriptlistener but it is referenced by name.
You can also reference an action set by index but I don't see a way to tell if it is selected.
Even in the GUI having just an action set selected is ignored by the Batch command. If an action or action step is selected Batch fills the selected set and action. If an action set is selected it defaults to the first set and first action.
You can also reference an action set by index but I don't see a way to tell if it is selected.
Even in the GUI having just an action set selected is ignored by the Batch command. If an action or action step is selected Batch fills the selected set and action. If an action set is selected it defaults to the first set and first action.
-
stat
How do you know what action selected in the panel Аct
many thanks for the explanation. I knew it!