Copy link to clipboard
Copied
Hello,
I am looking to write a script to rearrange my object styles (with much subgroups) according to a personal order.
Just a short example:
MY_PRINCIPAL_STYLE_HORIZONTAL
MY_SECOND_STYLE_HORIZONTAL
MY_PRINCIPAL_STYLE_VERTICAL
MY_SECOND_STYLE_VERTICAL​
In this specific case, I saw that it required :
002_MY_SECOND_STYLE_HORIZONTAL
001_MY_PRINCIPAL_STYLE_HORIZONTAL
004_MY_SECOND_STYLE_VERTICAL​
003_MY_PRINCIPAL_STYLE_VERTICAL001_MY_PRINCIPAL_STYLE_HORIZONTAL
002_MY_SECOND_STYLE_HORIZONTAL
003_MY_PRINCIPAL_STYLE_VERTICAL
004_MY_SECOND_STYLE_VERTICAL​MY_PRINCIPAL_STYLE_HORIZONTAL
MY_SECOND_STYLE_HORIZONTAL
MY_PRINCIPAL_STYLE_VERTICAL
MY_SECOND_STYLE_VERTICAL​With ChatGpt and Mate, I make three scripts for the moment. I'm stuck on part 2 taken from this post. This code app.menuActions.itemByID(113168).invoke(); doesn't always seem to execute correctly on each run.
I use Indesign 2021 in my work. Is there a better way to invoke this action?
Hi @RYR9 ,
to sort object styles by name you could also use this menu action:
app.menuActions.itemByName( "$ID/SortObjectStylesName" ).invoke();
However, you could first check if the menu action is available (enabled) in the context you are using it:
var mA = app.menuActions.itemByName( "$ID/SortObjectStylesName" );
if( mA.enabled )
{
mA.invoke();
}
else
{
alert( "ERROR: " + mA.name + "is currently not enabled." )
};
Kind regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Hi @RYR9 ,
to sort object styles by name you could also use this menu action:
app.menuActions.itemByName( "$ID/SortObjectStylesName" ).invoke();
However, you could first check if the menu action is available (enabled) in the context you are using it:
var mA = app.menuActions.itemByName( "$ID/SortObjectStylesName" );
if( mA.enabled )
{
mA.invoke();
}
else
{
alert( "ERROR: " + mA.name + "is currently not enabled." )
};
Kind regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Some panels with lists or trees allow a selection of multiple items.
Some panel associated menu actions will consider such a panel selection, or within a contextual click the hit item, and work on that. They require that the panel is open and that there is such a selection.
You can't simulate the effect via a scripted invoke(). Fallbacks might work on every item or give up.
I do not know whether this is the case for your menu actions, but your "doesn't always seem" sounds like that.
Alternatively you (or your AI) could try the myObjectStyle.move(LocationOptions.…,parentOrSibling) method, it should work without the panel.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now