ellipirelli
Explorer
ellipirelli
Explorer
Activity
‎Jul 08, 2020
08:36 AM
Hi, I have a script that changes the size of the artboard and the contents on the artboard and then exports it, but I noticed the exported png is off by a few pixel. var mm = 2.834645;
var px = 1;
var doc = app.activeDocument;
var preffix = "";
var suffix = "";
var foldername = "Icons"
var filepreffix = "Icon"
fullDocName = doc.fullName;
if (app.documents.length > 0) {
// PNG
var optionsPNG24 = new ExportOptionsPNG24();
optionsPNG24.saveAsHTML = true;
optionsPNG24.antiAliasing = true;
optionsPNG24.resolution = 72;
optionsPNG24.transparency = true;
var type = ExportType.PNG24;
app.executeMenuCommand('doc-color-rgb');
doc.artboards[0].artboardRect = [0, 171*px, 307*px, 0];
try {
var norm = doc.layers.getByName("Elemente");
if (norm) {
norm.locked = false;
app.activeDocument.layers["Elemente"].hasSelectedArtwork = true;
app.executeMenuCommand("group");
var normobj = norm.pageItems[0];
var heightTo = 135*px;
var scale = heightTo * 100 / normobj.height;
normobj.resize(scale, scale);
normobj.position = [0*mm, 0*mm];
var ab = doc.artboards[doc.artboards.getActiveArtboardIndex()];
var artboardRight = ab.artboardRect[2];
var artboardBottom = ab.artboardRect[3];
var myPageItem = doc.pageItems[0];
var horziontalCenterPosition = (artboardRight - myPageItem.width)/2;
var verticalCenterPosition = (artboardBottom + myPageItem.height)/.89;
myPageItem.position = [horziontalCenterPosition, verticalCenterPosition];
}
} catch (e) {}
try {
var rect = doc.layers.getByName("Ebene 2");
if (rect) {
rect.locked = false;
rect.pathItems[0].strokeWidth = 4;
rect.locked = false;
var rectobj = rect.pathItems[0];
var widthTo = 307*px;
var scale = widthTo * 100 / rectobj.width;
rectobj.resize(scale, scale);
rectobj.position = [0*mm, 171*px];
}
} catch (e) {}
var param = doc.name.split('.');
realDocName = param[0];
file = preffix+filepreffix+realDocName+'_og'+suffix;
folder = preffix+foldername;
var f = new Folder(doc.path + "/" + folder);
if (!f.exists)
f.create();
var saveName = new File ( f + "/" + file );
doc.exportFile(saveName, type, optionsPNG24);
doc.close(SaveOptions.DONOTSAVECHANGES);
doc = null;
app.open (fullDocName);
doc = app.activeDocument;
}
... View more
‎Jul 08, 2020
08:32 AM
I'm still having a bit of trouble about which is which. But getting there 😄
... View more
‎Jul 06, 2020
09:15 AM
2 Upvotes
Hi, I have actually found my own answer. var group = doc.layers["Norm"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "CompoundPathItem") {
group.pageItems[i].pathItems[0].filled = true;
group.pageItems[i].pathItems[0].fillColor = swatch.color;
}
}
... View more
‎Jul 06, 2020
04:52 AM
This does not make any change. Also the CompoundPathItem is part of a group. --> var normpath = norm.pageItems[0].pathItems[i]; Also tried the following: var group = doc.layers["Norm"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "CompoundPathItem") {
var normpath2 = group.pageItems[i];
//group.pageItems[i].remove();
if (normpath2.filled = true) {
normpath2.fillColor = swatch.color;
}
if (normpath2.stroked = true) {
normpath2.strokeColor = swatch.color;
}
}
}
... View more
‎Jul 06, 2020
02:07 AM
Thanks Mark, I actually tried secveral versions of this yesterday and it didn't work. I want to change the colors via script but the compound path items stay the same. The last thing I tried is this: var mm = 2.834645;
var px = 1;
var doc = app.activeDocument;
//CMYK
var grey = new CMYKColor();
grey.cyan = 10;
grey.magenta = 0;
grey.yellow = 5;
grey.black = 60;
if (app.documents.length > 0) {
doc.artboards[0].artboardRect = [0, 14.5*mm, 26*mm, 0];
var swatch = doc.swatches.add();
swatch.color = grey;
swatch.name = "Grey CMYK";
normlayer = doc.layers.getByName("Norm");
try {
if (doc.layers.getByName("Norm")) {
doc.layers.getByName("Norm").locked = false;
var norm = doc.layers.getByName("Norm");
norm.pageItems[0].pathItems.rectangle(-8.5*mm, 8.5*mm, 50.5*mm, 50.5*mm);
for(var i = 0; i < norm.pageItems[0].pathItems.length; i++){
var normpath = norm.pageItems[0].pathItems[i];
var normobj = norm.pageItems[0];
var ab = doc.artboards[0];
var artboardRight = ab.artboardRect[2];
var artboardBottom = ab.artboardRect[3];
var artboardX = ab.artboardRect[0];
var artboardY = ab.artboardRect[1];
var horziontalCenterPosition = (artboardRight - normobj.width)/1.36;
var verticalCenterPosition = (artboardY + normobj.height)/2;
normobj.position = [horziontalCenterPosition, verticalCenterPosition];
if (normpath.filled = true) {
normpath.fillColor = swatch.color;
}
if (normpath.stroked = true) {
normpath.strokeColor = swatch.color;
}
if (normpath.typename == "CompoundPathItem" && normpath.filled = true) {
normpath.fillColor = swatch.color;
}
if (normpath.typename == "CompoundPathItem" && normpath.stroked = true) {
normpath.strokeColor = swatch.color;
}
}
var place = norm.pageItems[0].pathItems[0];
place.filled = false;
place.stroked = false;
}
} catch (e) {}
var item = doc.pageItems[0];
var scale = 22;
item.resize(
scale ,
scale ,
true,
true,
true,
true,
scale ,
undefined);
doc.layers.add();
doc.layers[0].name = "Rectangle";
var rect = doc.layers.getByName("Rectangle");
rect.pathItems.roundedRectangle(25.7*mm, 14.2*mm, 25.7*mm, 14.19*mm, 2*mm, 2*mm, false);
rect.move(doc, ElementPlacement.PLACEATEND);
var rectobj = rect.pathItems[0];
var widthTo = 25.7*mm;
var scale = widthTo * 100 / rectobj.width;
rectobj.resize(scale, scale);
rectobj.position = [.15*mm, 14.344*mm];
rect.pathItems[0].strokeWidth = 0.88;
rect.pathItems[0].filled = false;
rect.pathItems[0].stroked = true;
rect.pathItems[0].strokeColor = swatch.color;
}
... View more
‎Jul 05, 2020
01:20 PM
I have a layer with a group and I want to change the color in filled and stroked elements, It works for PathItems but not for CompoundPaths. var mm = 2.834645;
var px = 1;
var doc = app.activeDocument;
fullDocName = doc.fullName;
var grey = new CMYKColor();
grey.cyan = 10;
grey.magenta = 0;
grey.yellow = 5;
grey.black = 60;
if (app.documents.length > 0) {
var swatch = doc.swatches.add();
swatch.color = grey;
normlayer = doc.layers.getByName("Norm");
try {
if (doc.layers.getByName("Norm")) {
doc.layers.getByName("Norm").locked = false;
var norm = doc.layers.getByName("Norm");
norm.pageItems[0].pathItems.rectangle(-8.5*mm, 8.5*mm, 50.5*mm, 50.5*mm);
for(var i = 0; i < norm.pageItems[0].pathItems.length; i++){
var normpath = norm.pageItems[0].pathItems[i];
var normobj = norm.pageItems[0];
var ab = doc.artboards[0];
var artboardRight = ab.artboardRect[2];
var artboardBottom = ab.artboardRect[3];
var artboardX = ab.artboardRect[0];
var artboardY = ab.artboardRect[1];
var horziontalCenterPosition = (artboardRight - normobj.width)/1.36;
var verticalCenterPosition = (artboardY + normobj.height)/2;
normobj.position = [horziontalCenterPosition, verticalCenterPosition];
if (normpath.filled = true) {
normpath.fillColor = swatch.color;
}
if (normpath.stroked = true) {
normpath.strokeColor = swatch.color;
}
}
var place = norm.pageItems[0].pathItems[0];
place.filled = false;
place.stroked = false;
}
} catch (e) {}
var item = doc.pageItems[0];
var scale = 22;
item.resize(
scale ,
scale ,
true,
true,
true,
true,
scale ,
undefined);
}
... View more
‎Jun 24, 2020
01:25 AM
1 Upvote
Thank you so much 😄
... View more
‎Jun 24, 2020
01:17 AM
1 Upvote
It worked, thank you 😄
... View more
‎Jun 24, 2020
12:49 AM
2 Upvotes
Hi, I have a quick question. I have a group that consists of paths , but one of the objects is a Text and I want the script to do something different with it than the path objects. I have tried using the following, but it does not work. var doc = app.activeDocument;
var group = doc.layers["Icon"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "TextFrameItem") {
group.pageItems[i].textRange.characterAttributes.fillColor = swatch.color;
}
} I also tried to delete the layer which did not work. var group = doc.layers["Icon"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "TextFrameItem") {
group.pageItems[i].remove();
}
}
... View more
‎Jun 24, 2020
12:30 AM
Hey, first of all I'm not posting the entire script because it is long. I will just do one color with ai format. var mm = 2.834645;
var px = 1;
var doc = app.activeDocument;
var preffix = "";
var suffix = "";
var foldername = "foldername"
var filepreffix = "icon_"
fullDocName = doc.fullName;
var grey = new CMYKColor();
grey.cyan = 10;
grey.magenta = 0;
grey.yellow = 5;
grey.black = 60;
var optionsAI = new IllustratorSaveOptions();
optionsAI.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
if (app.documents.length > 0) {
doc.artboards[0].artboardRect = [0, 14.5*mm, 26*mm, 0];
var swatch = doc.swatches.add();
swatch.color = grey;
swatch.name = "Grey CMYK";
textlayer = doc.layers.getByName("Text");
if (textlayer.visible){
textlayer.locked = false;
var group = doc.layers["Icon"].groupItems[0];
var lastIndex = (group.pageItems.length) - 1;
group.pageItems[lastIndex].remove();
if (doc.layers.getByName("icon")){
doc.layers.getByName("icon").locked = false;
var icon = doc.layers.getByName("icon");
icon.pageItems[0].pathItems.rectangle(-8.5*mm, 8.5*mm, 50.5*mm, 50.5*mm);
for(var i = 0; i < icon.pageItems[0].pathItems.length; i++){
var iconpath = icon.pageItems[0].pathItems[i];
var iconobj = icon.pageItems[0];
iconpath.strokeColor = swatch.color;
var ab = doc.artboards[0];
var artboardRight = ab.artboardRect[2];
var artboardBottom = ab.artboardRect[3];
var artboardX = ab.artboardRect[0];
var artboardY = ab.artboardRect[1];
var horziontalCenterPosition = (artboardRight - iconobj.width)/1.36;
var verticalCenterPosition = (artboardY + iconobj.height)/2;
iconobj.position = [horziontalCenterPosition, verticalCenterPosition];
}
var place = icon.pageItems[0].pathItems[0];
place.filled = false;
place.stroked = false;
}
var text = doc.layers.getByName("Text");
for(var i = 0; i < text.textFrames[i].length; i++){
textobj = text.textFrames[i];
textobj.autoLeading = true;
}
text.textFrames[0].resize(24*px, 29*px);
text.textFrames[1].resize(23*px, 29*px);
text.textFrames[2].resize(25*px, 20*px);
text.textFrames[3].resize(23*px, 29*px);
text.textFrames[0].TextFrameItem = TextType.AREATEXT;
text.textFrames[1].TextFrameItem = TextType.AREATEXT;
text.textFrames[2].TextFrameItem = TextType.AREATEXT;
text.textFrames[3].TextFrameItem = TextType.AREATEXT;
text.textFrames[0].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[1].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[2].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[3].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[0].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[0].textRange.characterAttributes.verticalScale = 100;
text.textFrames[1].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[1].textRange.characterAttributes.verticalScale = 100;
text.textFrames[2].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[2].textRange.characterAttributes.verticalScale = 100;
text.textFrames[3].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[3].textRange.characterAttributes.verticalScale = 100;
text.textFrames[0].position = [40*px, 35*px];
text.textFrames[1].position = [40*px, 35*px];
text.textFrames[2].position = [40*px, 30*px];
text.textFrames[3].position = [40*px, 27*px];
text.textFrames[0].textRange.characterAttributes.size = 12;
text.textFrames[1].textRange.characterAttributes.size = 12;
text.textFrames[2].textRange.characterAttributes.size = 12;
text.textFrames[3].textRange.characterAttributes.size = 9;
text.textFrames[0].textRange.characterAttributes.leading = 9;
text.textFrames[1].textRange.characterAttributes.leading = 9;
text.textFrames[2].textRange.characterAttributes.leading = 10;
text.textFrames[3].textRange.characterAttributes.leading = 7;
text.textFrames[0].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 10;
text.textFrames[1].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 12;
text.textFrames[2].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 11;
text.textFrames[3].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 8;
text.textFrames[0].textRange.characterAttributes.fillColor = swatch.color;
text.textFrames[1].textRange.characterAttributes.fillColor = swatch.color;
text.textFrames[2].textRange.characterAttributes.fillColor = swatch.color;
text.textFrames[3].textRange.characterAttributes.fillColor = swatch.color;
var pageItems = textlayer.pageItems;
for (var i = pageItems.length - 1; i >= 0; i--) {
if (pageItems[i].hidden)
pageItems[i].remove();
}
}
if (textlayer.visible == false){
textlayer.visible = true;
var group = doc.layers["Icon"].groupItems[0];
var lastIndex = (group.pageItems.length) - 1;
group.pageItems[lastIndex].remove();
if (doc.layers.getByName("icon")){
doc.layers.getByName("icon").locked = false;
var icon = doc.layers.getByName("icon");
icon.pageItems[0].pathItems.rectangle(-8.5*mm, 8.5*mm, 50.5*mm, 50.5*mm);
for(var i = 0; i < icon.pageItems[0].pathItems.length; i++){
var iconpath = icon.pageItems[0].pathItems[i];
var iconobj = icon.pageItems[0];
iconpath.strokeColor = swatch.color;
var ab = doc.artboards[0];
var artboardRight = ab.artboardRect[2];
var artboardBottom = ab.artboardRect[3];
var artboardX = ab.artboardRect[0];
var artboardY = ab.artboardRect[1];
var horziontalCenterPosition = (artboardRight - iconobj.width)/2;
var verticalCenterPosition = (artboardY + iconobj.height)/2;
iconobj.position = [horziontalCenterPosition, verticalCenterPosition];
}
var place = icon.pageItems[0].pathItems[0];
place.filled = false;
place.stroked = false;
}
textlayer.locked = false;
textlayer.remove();
var group = doc.layers["Icon"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "TextFrameItem") {
group.pageItems[i].remove();
}
}
}
var item = doc.pageItems[0];
var scale = 22;
item.resize(
scale ,
scale ,
true,
true,
true,
true,
scale ,
undefined);
var param = doc.name.split('.');
realDocName = param[0];
file = preffix+filepreffix+realDocName+'_grey'+suffix;
folder = preffix+foldername;
var f = new Folder(doc.path + "/" + folder);
if (!f.exists)
f.create();
var saveName = new File ( f + "/" + file );
doc.saveAs( saveName, optionsAI );
doc.close(SaveOptions.DONOTSAVECHANGES);
doc= null;
app.open (fullDocName);
doc = app.activeDocument;
}
... View more
‎Jun 22, 2020
09:20 AM
This works really well, however I have a sceond question. Is it possible to adapt it fpr a text element? I've tried this but it doesn't work. var app = app.activeDocument;
var group = app.layers["Icon"].groupItems[0];
for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
if (group.pageItems[i].typename == "TextFrameItem") {
group.pageItems[i].remove();
}
}
... View more
‎Jun 22, 2020
09:18 AM
Hi, sorry this is so late. I have created icons and 4 different Scripts that export then in different ways, for instance several different colors, sizes, with a circle in the background or without a circle. Every script saves or exports the icons as ai, eps, svg and png into folders. The above script is a part of each export and not an extra script that runs at the end. Right now it looks like this: var app = app.activeDocument;
textlayer = app.layers.getByName("Text");
if (textlayer.visible){
textlayer.locked = false;
var group = app.layers["Icon"].groupItems[0];
var lastIndex = (group.pageItems.length) - 1;
group.pageItems[lastIndex].remove();
if (app.layers.getByName("icon")){
app.layers.getByName("icon").locked = false;
var icon = bks.layers.getByName("icon");
icon.pageItems[0].pathItems.rectangle(-8.5*mm, 8.5*mm, 50.5*mm, 50.5*mm);
for(var i = 0; i < icon.pageItems[0].pathItems.length; i++){
var iconpath = icon.pageItems[0].pathItems[i];
var iconobj = icon.pageItems[0];
iconpath.strokeColor = swatch.color;
var ab = bks.artboards[0];
var artboardRight = ab.artboardRect[2];
var artboardBottom = ab.artboardRect[3];
var artboardX = ab.artboardRect[0];
var artboardY = ab.artboardRect[1];
var horziontalCenterPosition = (artboardRight - iconobj.width)/1.36;
var verticalCenterPosition = (artboard + iconobj.height)/2;
iconobj.position = [horziontalCenterPosition, verticalCenterPosition];
}
var place = icon.pageItems[0].pathItems[0];
place.filled = false;
place.stroked = false;
}
var text = app.layers.getByName("Text");
for(var i = 0; i < text.textFrames[i].length; i++){
textobj = text.textFrames[i];
textobj.autoLeading = true;
}
text.textFrames[0].resize(24*px, 29*px);
text.textFrames[1].resize(23*px, 29*px);
text.textFrames[2].resize(25*px, 20*px);
text.textFrames[3].resize(23*px, 29*px);
text.textFrames[0].TextFrameItem = TextType.AREATEXT;
text.textFrames[1].TextFrameItem = TextType.AREATEXT;
text.textFrames[2].TextFrameItem = TextType.AREATEXT;
text.textFrames[3].TextFrameItem = TextType.AREATEXT;
text.textFrames[0].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[1].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[2].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[3].figureStyle = FigureStyleType.PROPORTIONAL;
text.textFrames[0].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[0].textRange.characterAttributes.verticalScale = 100;
text.textFrames[1].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[1].textRange.characterAttributes.verticalScale = 100;
text.textFrames[2].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[2].textRange.characterAttributes.verticalScale = 100;
text.textFrames[3].textRange.characterAttributes.horizontalScale = 100;
text.textFrames[3].textRange.characterAttributes.verticalScale = 100;
text.textFrames[0].position = [40*px, 35*px];
text.textFrames[1].position = [40*px, 35*px];
text.textFrames[2].position = [40*px, 30*px];
text.textFrames[3].position = [40*px, 27*px];
text.textFrames[0].textRange.characterAttributes.size = 12;
text.textFrames[1].textRange.characterAttributes.size = 12;
text.textFrames[2].textRange.characterAttributes.size = 12;
text.textFrames[3].textRange.characterAttributes.size = 9;
text.textFrames[0].textRange.characterAttributes.leading = 9;
text.textFrames[1].textRange.characterAttributes.leading = 9;
text.textFrames[2].textRange.characterAttributes.leading = 10;
text.textFrames[3].textRange.characterAttributes.leading = 7;
text.textFrames[0].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 10;
text.textFrames[1].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 12;
text.textFrames[2].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 11;
text.textFrames[3].paragraphs[0].paragraphAttributes.desiredLetterSpacing = 8;
text.textFrames[0].textRange.characterAttributes.fillColor = swatch.color;
text.textFrames[1].textRange.characterAttributes.fillColor = swatch.color;
text.textFrames[2].textRange.characterAttributes.fillColor = swatch.color;
text.textFrames[3].textRange.characterAttributes.fillColor = swatch.color;
var pageItems = textlayer.pageItems;
for (var i = pageItems.length - 1; i >= 0; i--) {
if (pageItems[i].hidden)
pageItems[i].remove();
}
}
var param = app.name.split('.');
realDocName = param[0];
file = preffix+filepreffix+realDocName+'_grau'+suffix;
folder = preffix+foldername;
var f = new Folder(app.path + "/" + folder);
if (!f.exists)
f.create();
var saveName = new File ( f + "/" + file );
bks.saveAs( saveName, optionsEPS );
bks.close(SaveOptions.DONOTSAVECHANGES);
bks = null;
app.open (fullDocName);
app = app.activeDocument;
I'm sure my script is way too complimanted, but it works so far (for the most part) and it's my first time 🙂
... View more
‎Jun 15, 2020
05:35 AM
I think I need to explain in more detail. The script is changing things in the file and then exporting it into the formats ai, eps, svg and png. In the exported ai file the hidden pageItems inside are simply not removed.
... View more
‎Jun 15, 2020
05:12 AM
Hi, it worked when exporting the eps and svg files but not with the ai files. Any idea? Kind regards, Elli
... View more
‎Jun 14, 2020
12:04 PM
Hi, I need help with a small issue. I tried several delete hidden layer scripts I found but none of them worked. I wan to delete the hidden layers in Layer "Text" before I export the file. I am using this to make changes to the layers beforehand: if (bks.layers.getByName("Text")){ bks.layers.getByName("Text").locked = false; var text = bks.layers.getByName("Text"); ... }
... View more
‎Jun 09, 2020
02:37 AM
Thank you for your help. The simple code from above already helped. I want to try this out later. I'm actually having a bit of trouble with the terminology, especially a lot of the explanation given here. I need more examples to understand it all.
... View more
‎Jun 09, 2020
02:33 AM
Hi, the first example worked very well for me, thank you very much 🙂 And I relize that I hadn't named the layer of the compound path. I had however previously tried that to find a solution myself. thank you very much 😄
... View more
‎Jun 09, 2020
02:31 AM
1 Upvote
Thanks. I already did all the reading I could to find the solution on my own. I would not have posted here if that weren't the case. My main source is this: https://illustrator-scripting-guide.readthedocs.io/
... View more
‎Jun 07, 2020
12:44 PM
Hi, I need to delete the last layer in a group or delete a CompoundPath layer that is part of a group. Or delete a layer of a group that has a certain name. I think I need to loop through the function but I am not sure how. These are my layers: The amount of layers can vary... Here iy my script: if (bks.layers.getByName("icon")){
bks.layers.getByName("icon").locked = false;
var icon = bks.layers.getByName("icon");
for(var i = 0; i < icon.pageItems[0].pathItems.length; i++){
var iconpath = icon.pageItems[0].pathItems[i];
var iconobj = icon.pageItems[0];
iconpath.strokeColor = grau;
var ab = bks.artboards[0];
var artboardRight = ab.artboardRect[2];
var artboardBottom = ab.artboardRect[3];
var artboardX = ab.artboardRect[0];
var artboardY = ab.artboardRect[1];
var horziontalCenterPosition = (artboardRight - iconobj.width)/2;
var verticalCenterPosition = (artboardY + iconobj.height)/2;
iconobj.position = [horziontalCenterPosition, verticalCenterPosition];
}
}
... View more
‎Jun 07, 2020
10:58 AM
1 Upvote
Thank you so much. It worked like a charm.
... View more
‎May 06, 2020
03:31 AM
Hi, I have a Javascript Problem. I created a script that exports an vector icon in different formats, for print (eps and ai) and for web (png and svg). My Original DocumentColorSpace is CMYK. When I export the web files the colors deviate from what I defined in the file, because the DocumentColorSpace is still CMYK and not RGB. I can only change it if I create a new document. Is there another way? var grey = new RGBColor();
grey.red = 124;
grey.green = 131;
grey.blue = 132;
var param = bks.name.split('.');
realDocName = param[0];
file = preffix+filepreffix+realDocName+'_grau'+suffix;
folder = preffix+foldername;
var f = new Folder(bks.path + "/" + folder);
if (!f.exists)
f.create();
var saveName = new File ( f + "/" + file );
bks.exportFile(saveName, type, optionsSVG);
bks.close(SaveOptions.DONOTSAVECHANGES);
bks = null;
app.open (fullDocName);
bks = app.activeDocument;
... View more