// взять цвета с выделенных объектов для покраски текста через стили,
// текст также должен быть выделен.
var doc = app.activeDocument;
var sel = doc.selection;
var myGS = new Array;
var count = 0;
for ( i = 0; i < sel.length; i++ )
{
if ( sel[ i ].typename == "TextFrame" ) { var temp = sel[ i ]; temp.selected = false; sel = doc.selection; } // turn off text from sel
else { count = count + 1 ; };
}
// objects, graphic style's unique names
getGrStyles ( sel, "_temp - " + i ); // add new styles by selection
doc.selection = null;
temp.selected = true;
sel = doc.selection
sel [ 0 ].textRange.characterAttributes.fillColor = new NoColor() ;
for ( i = 0; i < count ; i++ )
{
doc.graphicStyles[ doc.graphicStyles.length - count + i ].mergeTo( sel [ 0 ] );
doc.graphicStyles[ doc.graphicStyles.length - count + i ].remove();
}
//alert ( myGS );
function getGrStyles(arrObj, prefStyle) {
var Action = "AddGraphicStyle"
var ActionSet = "ApperanceColorText"
var actionStr = ['/version 3',
'/name [ 18',
' 4170706572616e6365436f6c6f7254657874',
']',
'/isOpen 1',
'/actionCount 1',
'/action-1 {',
' /name [ 15',
' 416464477261706869635374796c65',
' ]',
' /keyIndex 0',
' /colorIndex 0',
' /isOpen 0',
' /eventCount 1',
' /event-1 {',
' /useRulersIn1stQuadrant 0',
' /internalName (ai_plugin_styles)',
' /localizedName [ 14',
' 47726170686963205374796c6573',
' ]',
' /isOpen 0',
' /isOn 1',
' /hasDialog 1',
' /showDialog 0', // turn dialog off
' /parameterCount 1',
' /parameter-1 {',
' /key 1835363957',
' /showInPalette -1',
' /type (enumerated)',
' /name [ 17',
' 4e65772047726170686963205374796c65',
' ]',
' /value 1',
' }',
' }',
'}'].join('\n');
createAction ( actionStr ) ;
function createAction (str) {
var f = new File('~/Tracer.aia');
f.open('w');
f.write(str);
f.close();
app.loadAction(f);
f.remove();
}
for ( a = 0; a < arrObj.length; a++ )
{
app.executeMenuCommand("deselectall");
arrObj[a].selected = true;
var GS = app.activeDocument.graphicStyles.length;
app.doScript(Action, ActionSet);
redraw();
myGS[a] = app.activeDocument.graphicStyles[GS];
sn = prefStyle + (GS+1);
myGS[a].name = sn;
};
app.unloadAction(ActionSet,'');
return myGS;
};