[AI CC-CC2022] Что то не так с кодировкой или глюк Illustrator?

  • Автор темы Автор темы 929151
  • Дата начала Дата начала

929151

Топикстартер
12 лет на форуме
Сообщения
4
Реакции
0
Код:
function addLabColorToSwatch(L, a, b, swatchName, swatchGroup) {

    var color = new LabColor();
    color.l = L;
    color.a = a;
    color.b = b;
    try {
        var swatchgroup = app.activeDocument.swatchGroups.getByName(swatchGroup);
        swatchgroup.name = swatchGroup;
    } catch (e) {
        var swatchgroup = app.activeDocument.swatchGroups.add(swatchGroup);
        swatchgroup.name = swatchGroup;
    };
    var newSpot = app.activeDocument.spots.add();
    newSpot.name = swatchName;
    newSpot.colorType = ColorModel.SPOT;
    newSpot.spotKind = SpotColorKind.SPOTLAB;
    newSpot.color = color;
    var newSpotColor = new SpotColor();
    newSpotColor.spot = newSpot;
    swatchgroup.addSpot(newSpot);
    return true;
}
addLabColorToSwatch(1, 2, 3, "нью ЛАБ", "ТЕСТ");
Текст [нью ЛАБ] записывает как [РЅСЊСЋ ЛАБ], а [ТЕСТ] нормально.
 
так же. Color Group по русски, а Swatch name [РЅСЊСЋ ЛАБ].
htmlimage.png
 
решение простое - менять имя свотча

Код:
function addLabColorToSwatch(L, a, b, swatchName, swatchGroup) {

    var color = new LabColor();
    color.l = L;
    color.a = a;
    color.b = b;
    try {
        var swatchgroup = app.activeDocument.swatchGroups.getByName(swatchGroup);
        swatchgroup.name = swatchGroup;
    } catch (e) {
        var swatchgroup = app.activeDocument.swatchGroups.add(swatchGroup);
        swatchgroup.name = swatchGroup;
    };
    var newSpot = app.activeDocument.spots.add();
 
    newSpot.colorType = ColorModel.SPOT;
    newSpot.spotKind = SpotColorKind.SPOTLAB;
    newSpot.color = color;
    var newSpotColor = new SpotColor();
    newSpotColor.spot = newSpot;
    swatchgroup.addSpot(newSpot);

    var a = swatchgroup.getAllSwatches();
    var b = a[a.length-1];
    b.name = swatchName;
    return true;
}
addLabColorToSwatch(1, 2, 3, "нью ЛАБ", "ТЕСТ");
 
  • Спасибо
Реакции: _MBK_ и 929151
Зачем такие танцы в гамаке? 'hz' Вполне достаточно так
Код:
function addLabColorToSwatch(L, a, b, swatchName, swatchGroup) {

    var color = new LabColor();
    color.l = L;
    color.a = a;
    color.b = b;
    try {
        var swatchgroup = app.activeDocument.swatchGroups.getByName(swatchGroup);
        swatchgroup.name = swatchGroup;
    } catch (e) {
        var swatchgroup = app.activeDocument.swatchGroups.add(swatchGroup);
        swatchgroup.name = swatchGroup;
    };
    var newSpot = app.activeDocument.spots.add();
 
    newSpot.colorType = ColorModel.SPOT;
    newSpot.spotKind = SpotColorKind.SPOTLAB;
    newSpot.color = color;
   
    var newSpotColor = new SpotColor();
    newSpotColor.spot = newSpot;
   
    var b=swatchgroup.addSpot(newSpot);
    newSpot.name=swatchName;

    return true;
}
addLabColorToSwatch(1, 2, 3, "нью ЛАБ", "ТЕСТ");
 
Последнее редактирование модератором: