femkeblanco
Guide
femkeblanco
Guide
Activity
‎Oct 01, 2020
12:39 PM
The last three lines would copy the pathItems in compoundPathItems, not the compoundPathItems themselves. To copy the compoundPathItems themselves: for (var i = 0; i < srcDoc.compoundPathItems.length; i++) {
srcDoc.compoundPathItems[i].duplicate(targetDoc, ElementPlacement.PLACEATBEGINNING);
}
... View more
‎Sep 28, 2020
12:27 PM
2 Upvotes
You can access the fillColor of any of the pathItems in a compoundPathItem, e.g. var paths = app.activeDocument.compoundPathItems[0].pathItems;
var c1 = paths[0].fillColor;
alert( c1.typename + ", C: " + c1.cyan + ", M: " + c1.magenta + ", Y: " + c1.yellow ); But the fillColor has but few properties to access, i.e. typename and the values of the components (CMYK or RGB).
... View more
‎Sep 27, 2020
03:07 AM
If you mean "packing" (as in bin packing), then there is none.
... View more
‎Sep 25, 2020
04:04 PM
2 Upvotes
Can I respectfully suggest that you rephrase the question in a better way?
... View more
‎Sep 24, 2020
06:57 PM
Autosizing appears to be available for area type, but not path type, in CC. (It's not available to me in CS6). https://helpx.adobe.com/illustrator/using/area-text-autosizing.html
... View more
‎Sep 24, 2020
06:32 PM
2 Upvotes
var win = new Window ("dialog{text:'Which files to close?'}");
var checkboxes = [];
var names = [];
for (var i = app.documents.length - 1; i > -1; i--){
names[i] = app.documents[i].name;
checkboxes[i] = win.add ("checkbox", undefined, names[i]);
}
win.quitBtn = win.add ("button", undefined, "OK");
win.defaultElement = win.quitBtn;
for (var j = 0; j < checkboxes.length; j++) {
(function (j) {
checkboxes[j].onClick = function () {
app.documents[names[j]].close();
};
})(j);
}
win.show();
... View more
‎Sep 24, 2020
08:04 AM
Copy your circle. Select the "Type on a Path Tool", click the 9 o'clock anchor on the circle and enter your text. Select the black arrow tool. On the circle, close to the 9 o'clock anchor, you should see 2 brackets close to each other (beginning and end). Drag the lowermost (end) bracket counter clockwise to the 3 o'clock anchor position. Your text will be confined to the upper half of a circle. Click "Align centre" (in the control panel on top of the document). Your text will be in the centre. Select your text and press and hold Ctrl and shift and press > or < to increase or decrease your text size until it fits. Paste your copied circle and repeat steps 2-5 on the lower half of this circle. If you want to flip the lower half text upwards, double click the type tool (in the tool panel on the left of the document) and check flip.
... View more
‎Sep 23, 2020
12:24 AM
You're right, but I think this will only work for a script-targeted and not a user-selected textFrame (although this may not matter if all you have is one textFrame in the document). Also, while you can get the required properties, I can't think of a way to draw a rectangle around a selected textRange. Again, I may be mistaken though.
... View more
‎Sep 22, 2020
01:05 PM
I may be mistaken, but, no, I don't think so.
... View more
‎Sep 22, 2020
12:01 PM
Alternatively, see if this works for you: var text1 = app.selection[0];
if (text1 == undefined || text1.typename != "TextFrame") {
alert("You did not select a textFrame.");
} else {
var string = "Family: " + text1.textRange.characterAttributes.textFont.family + "\
Name: " + text1.textRange.characterAttributes.textFont.name + "\
Style: " + text1.textRange.characterAttributes.textFont.style + "\
Size: " + text1.textRange.characterAttributes.size + "\
Leading: " + text1.textRange.characterAttributes.leading + "\
Tracking: " + text1.textRange.characterAttributes.tracking;
}
var top = app.selection[0].position[1];
var left = app.selection[0].position[0];
var h = app.selection[0].height;
var w = app.selection[0].width;
var rect1 = app.activeDocument.pathItems.rectangle(top, left, w, h);
rect1.strokeColor = app.activeDocument.swatches["CMYK Cyan"].color;
rect1.strokeWidth = 2.5;
rect1.filled = false;
var rect2 = app.activeDocument.pathItems.rectangle(top, left-200, 200, 200);
rect2.stroked = false;
var text2 = app.activeDocument.textFrames.areaText(rect2);
text2.contents = string;
text2.textRange.characterAttributes.textFont = textFonts["ArialMT"];
text2.textRange.characterAttributes.size = 15;
text2.textRange.fillColor = app.activeDocument.swatches["CMYK Cyan"].color;
... View more
‎Sep 22, 2020
10:56 AM
This should give you the properties of a selected textFrame in an alert window. var text1 = app.selection[0];
if (text1 == undefined || text1.typename != "TextFrame") {
alert("You did not select a textFrame.");
} else {
alert("family: " + text1.textRange.characterAttributes.textFont.family + "\
Name: " + text1.textRange.characterAttributes.textFont.name + "\
Style: " + text1.textRange.characterAttributes.textFont.style + "\
Size: " + text1.textRange.characterAttributes.size + "\
Leading: " + text1.textRange.characterAttributes.leading + "\
Tracking: " + text1.textRange.characterAttributes.tracking);
} It is possible to make it into text in the document, but then you will have to delete it once you have finished with it.
... View more
‎Sep 19, 2020
06:11 AM
1 Upvote
This is a dirty mock-up which does it. (Dirty because it uses Divide Objects Below through executeMenuCommand to get the tangent of the curve, which—as said—is the crux of the problem.) Be warned, there are many variables which will cause failure. But the point is, it can be done. // select dot
var items = app.activeDocument.pathItems;
var railway = items["railway"];
railway.locked = true;
app.executeMenuCommand("Find Appearance menu item");
var rects = [];
for (var i = selection.length - 1; i > -1; i--) {
var x = selection[i].position[0] + (selection[i].width/2);
var y = selection[i].position[1] - (selection[i].height/2);
selection[i].remove();
rects[i] = items.rectangle(y + 12.5, x - 5, 10, 25);
rects[i].name = "station" + i;
rects[i].strokeColor = app.activeDocument.swatches["Black"].color;
rects[i].fillColor = app.activeDocument.swatches["White"].color;
rects[i].locked = true;
}
for (var i = 0; i < rects.length; i++) {
rects[i].locked = false;
var params = [rects[i].top, rects[i].left, rects[i].width, rects[i].height];
var tempRailway = railway.duplicate();
tempRailway.name = "tempRailway";
tempRailway.move(rects[i], ElementPlacement.PLACEBEFORE);
tempRailway.locked = false;
tempRailway.selected = true;
app.executeMenuCommand("Knife Tool2");
app.activeDocument.selection = null;
if (items[1].top > items[0].top) {
items[1].moveBefore(items[0]);
}
items[0].translate(0, -1);
items[0].selected = true;
app.executeMenuCommand("Knife Tool2");
items[0 + 1].remove();
var T = items[0].height / items[0].width;
var x1 = items[0].pathPoints[0].anchor[0];
var y1 = items[0].pathPoints[0].anchor[1];
var x2 = items[0].pathPoints[2].anchor[0];
var y2 = items[0].pathPoints[2].anchor[1];
if ((x1 < x2) && (y1 > y2)) {
var degree = 90 - (Math.atan(T) * (180 / Math.PI));
} else if ((x1 < x2) && (y1 < y2)) {
var degree = -90 + (Math.atan(T) * (180 / Math.PI));
}
items[0].remove();
rects[i] = app.activeDocument.pathItems.rectangle(params[0], params[1], params[2], params[3]);
rects[i].rotate(degree);
rects[i].move(railway, ElementPlacement.PLACEAFTER);
rects[i].locked = true;
}
railway.move(rects[0], ElementPlacement.PLACEAFTER);
... View more
‎Sep 18, 2020
11:20 AM
The purpose of the script appears to be to match the number and name of the artboard, i.e. X - Artboard X. So try this: var AB = app.activeDocument.artboards;
for(var i = 0; i < AB.length; i++){
AB[i].name = "Artboard " + (i + 1);
}
... View more
‎Sep 18, 2020
01:53 AM
The crux is getting the tangent of the curve where there's a rectangle and therefore the angle of rotation of the rectangle, so that the two are "aligned".
... View more
‎Sep 18, 2020
01:40 AM
1 Upvote
There's a missing } in the correct answer. Add one to the line before last. I.e it should look like this function renameArtboards(){
var docRef = app.activeDocument;
var aB = docRef.artboards;
for(var a=0; a<aB.length; a++){
var curAB = aB;
curAB.name = "Artboard " + [a+1];
}
}
renameArtboards();
... View more
‎Sep 17, 2020
06:11 AM
Thanks a lot. I'll try this today.
... View more
‎Sep 16, 2020
04:47 PM
Hi Mark. Could you possibly provide more details on how you did this with the Extendscript Debugger and Visual Studio Code? Thanks in advance.
... View more
‎Sep 15, 2020
12:37 AM
2 Upvotes
You're welcome. (And thank you for method of finding the menuCommandStrings; I did not know that.) And, yes, this is nowhere to be found in the Adobe documents, because I think they are unofficial experiments (literally "off the books"). The fact that we know about them and are told about them on this forum by fellow users goes to show what a goldmine of help this forum is. It goes without saying (but I'm saying it): We are all grateful to the "oldtimers" here who discovered, shared and documented all of this.
... View more
‎Sep 14, 2020
12:23 PM
3 Upvotes
This applies Gaussian blur to the paths in the layer called "Layer 1" using applyEffect. For details, see the links above. var items = app.activeDocument.layers["Layer 1"].pathItems;
XMLstring = XMLstring = '<LiveEffect name="Adobe PSL Gaussian Blur"><Dict data="R blur 9.974 I PrevDres 300 "/></LiveEffect>';
for (var i = 0; i < items.length; i++) {
items[i].applyEffect(XMLstring);
}
... View more
‎Sep 14, 2020
12:07 AM
4 Upvotes
Effects are applied to selected paths, not layers. Once you've selected the paths in question, you can use executeMenuCommand("menuCommandString") to apply effects. The snippet below selects the paths in the layer called "Layer 1" and applies a "Zig Zag" effect, the menuCommandString for which is "Live Zig Zag". var items = app.activeDocument.pageItems;
for (var i = 0; i < items.length; i++) {
if (items[i].layer.name == "Layer 1") {
items[i].selected = true;
}
}
app.executeMenuCommand("Live Zig Zag"); For a list of menuCommandStrings for executeMenuCommand(), see https://ten5963.wordpress.com/illustrator-ccver-22-menu-commands-list/ (It's unfortunate that you choose Gaussian blur, because the menuCommandString for it doesn't work, at least not for me in CS6.) executeMenuCommand() is an inconvenient way to apply effects because it brings up a dialogue window for you to enter parameters. Another (more complicated) way to apply effects is applyEffect(). If you wish to pursue this, see https://community.adobe.com/t5/illustrator/applying-live-effects-offset-path-in-illustrator-using-as/td-p/9481564?page=1 https://community.adobe.com/t5/illustrator/pageitem-applyeffect-liveeffectxml/td-p/7315221?page=1 http://aiscripts.com/apply-live-effect-applyeffect-liveeffectxml/
... View more
‎Sep 12, 2020
01:18 AM
Try this: https://community.adobe.com/t5/illustrator/i-need-a-script-that-groups-filled-paths-by-color-for-paintings-by-numbers/m-p/11394863?page=1
... View more
‎Sep 05, 2020
10:47 PM
I cannot see why the above two scripts are not working. You could try the snippet below, but it's for all pageItems in the document, not selected items. It doesn't work for selected items and again I'm unsure why. (I would be grateful if someone could advise on why it works on the "pageItems" or "pathItems" collection but not on the "selection" collection.) var items = app.activeDocument.pageItems;
for (var i = 0; i < items.length - 1; i++) {
for (var j = 0; j < items.length - i - 1; j++) {
if (items[j].top > items[j + 1].top) {
items[j].moveAfter(items[j+1]);
}
}
}
... View more
‎Sep 05, 2020
11:58 AM
1 Upvote
Object>Path>Offset Path: Creates a second offset path. Effect>Path>Offset Path: Creates an effect, an appearance attribute, i.e. the path appears to be offset. If you select the path or view it in Outline mode (Ctrl+Y), you'll see the path as it is underneath. It only becomes an offset path when you click Object>Expant Appearance. Plus, it does not create a second path.
... View more
‎Sep 05, 2020
11:41 AM
https://helpx.adobe.com/uk/illustrator/using/clipping-masks.html
... View more
‎Sep 04, 2020
11:31 AM
1 Upvote
I am unsure what you are trying to achieve, but you can manually create a graphic style where the fill is above the stroke, save it and apply it through a script.
... View more
‎Sep 04, 2020
10:37 AM
1 Upvote
You can also apply appearance attributes by applying a graphic style: var Text = app.activeDocument.textFrames["someText"];
app.activeDocument.graphicStyles["graphicStyleName"].applyTo(Text);
... View more
‎Aug 31, 2020
02:44 AM
1 Upvote
If you're asking how to run the code: Copy and paste it in a jsx file. (You can create a txt file and change the extension to jsx.) Then, while your document is open in Illustrator, go to File > Scripts > Other Script (Ctrl+F12). Find your script and open it.
... View more
‎Aug 28, 2020
11:15 AM
1 Upvote
Replace the line (which is line 100 in the above script) txt.contents = n; with these two lines var x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
txt.contents = x[n]; The script will fail if you go beyond "Z".
... View more
‎Aug 25, 2020
11:06 AM
1 Upvote
I tried the script on this thread in CS6 and it seems to be working fine for me. (Thank you, Charu.)
... View more