m1b
Community Expert
m1b
Community Expert
Activity
‎Sep 08, 2020
04:16 PM
I didn't know that. Thanks! 🙂
... View more
‎Aug 29, 2020
03:40 PM
Yes absolutely! 🙂 I learned from renél80416020's post too! (Apologies for my embarrassing start to this thread—I forgot you were a more experienced scripter.)
... View more
‎Aug 19, 2020
07:39 PM
You're welcome!
... View more
‎Aug 17, 2020
10:27 PM
1 Upvote
you're welcome,
ScreenMode.FULLSCREEN
used to be rock solid in previous versions. Lately it has given me mixed results, it not always work. At least setting Preview off still works, that's the real time saver.
... View more
‎Aug 17, 2020
10:19 PM
redraw() also helps when applying Effects or LiveTracing. Sometimes (not always) it's necessary to redraw the screen. Problem is to tell when, Illustrator is like a wild beast we have to domesticate.
... View more
‎Aug 17, 2020
02:31 AM
Yes! Thank you MilosR. kyoung_namk48754987, please look at the difference between the OPs script and CarlosCantos' below. Amazing difference in performance!
... View more
‎Aug 14, 2020
04:31 AM
That appears to have worked. Thank you both. femkeblanco, I was moving each item one at a time as I came across them for a color check. When I had the issue deleting the layers I thought it was a timing issue, first thought was if I could move all items at once then remove layers may help with the timing. So I collected all pageItems by color into an array, grouped them, then moved them to the layer created. Code, its messy right now but it works with the backwards iteration. If you all know of a way to do this efficently please let me know. //@include "../utils/json2.jsx"
doc = app.activeDocument
drillBoxes()
function drillBoxes(){
allPageItems = filterPageItems()
seps = seprateItems(allPageItems)
moveToLayer(seps)
removeEmptyLayers(doc.layers)
}
function addToGroup(arr){
groupCollect = doc.groupItems.add()
for(i=0; i<arr.length; i++){
arr[i].move(groupCollect, ElementPlacement.PLACEATBEGINNING)
}
return groupCollect
}
function moveToLayer(sepObj, callback){
for(y=0; y < sepObj.colors; y++){
nGroup = addToGroup(seps[seps.colornames[y]])
nGroup.move(doc.layers[seps.colornames[y]], ElementPlacement.PLACEATBEGINNING)
}
}
function seprateItems(allPageItems){
//Move all items at once?
createdLayers = {}
createdLayers['colors'] = 0
createdLayers['colornames'] = []
len = allPageItems.length
for(z=0; z < len; z++){
j = allPageItems[z].length - 1
while(j >= 0){
currItem = allPageItems[z][j]
if(currItem.typename === 'CompoundPathItem'){
if(currItem.pathItems.length){
if(currItem.pathItems[0].filled){
currColor = currItem.pathItems[0].fillColor
}else{
currColor = currItem.pathItems[0].strokeColor
}
if(currColor.constructor.name === 'SpotColor'){
if(currColor.spot.name === '[Registration]'){
currItem.remove()
j--
continue
}
if(createdLayers[currColor.spot.name + 'color']){
createdLayers[currColor.spot.name].push(currItem)
}else{
addLayer(currColor.spot.name, [50, 50, 50])
doc.layers[currColor.spot.name].zOrder(ZOrderMethod.SENDTOBACK)
createdLayers[currColor.spot.name] = []
createdLayers[currColor.spot.name].push(currItem)
createdLayers['colors'] += 1
createdLayers['colornames'].push(currColor.spot.name)
createdLayers[currColor.spot.name + 'color'] = true
}
}else{
currItem.remove()
}
}else{
curItem.remove()
j--
continue
}
}else{
if(currItem.fillColor.constructor.name === 'SpotColor' || currItem.strokeColor.constructor.name === 'SpotColor'){
if(currItem.filled){
currColor = currItem.fillColor
}else{
currColor = currItem.strokeColor
}
if(currColor.spot.name === '[Registration]'){
currItem.remove()
j--
continue
}
if(createdLayers[currColor.spot.name + 'color']){
createdLayers[currColor.spot.name].push(currItem)
}else{
addLayer(currColor.spot.name, [50, 50, 50])
doc.layers[currColor.spot.name].zOrder(ZOrderMethod.SENDTOBACK)
createdLayers[currColor.spot.name] = []
createdLayers[currColor.spot.name].push(currItem)
createdLayers['colors'] += 1
createdLayers['colornames'].push(currColor.spot.name)
createdLayers[currColor.spot.name + 'color'] = true
}
}else{
currItem.remove()
}
}
j--
}
}
return createdLayers
callback()
}
function filterPageItems(){
collect = []
docLayers = doc.layers
for(i=0; i < docLayers.length; i++){
currLayer = docLayers[i]
returnArr = []
collectedPageItems = pageItemCustomRecursive(currLayer, returnArr)
collect.push(collectedPageItems)
}
// cleanCollect = twoDeArraytoOneDe(collect)
return collect
}
function pageItemCustomRecursive(parent, returnItems){
if(parent.typename == "Layer" && parent.layers.length > 0){
var layers = parent.layers
for( var i = 0; i < layers.length; i++ ) {
var subLayer = layers[i]
pageItemRecursive(subLayer, returnItems)
}
}
var items = parent.pageItems
for( var j = 0; j < items.length; j++ ){
var curItem = items[j]
if(curItem.typename == "GroupItem"){
pageItemRecursive(curItem, returnItems)
}else if(curItem.typename == "MeshItem" || "PlacedItem" || "SymbolItem" || "RasterItem" || "NonNativeItem" || "PluginItem" || "PathItem" || "CompoundPathItem"){
returnItems.push(curItem)
}
}
return returnItems
}
function removeEmptyLayers(arr){
$.writeln(arr)
app.redraw()
for(i=arr.length-1; i >= 0; i--){
$.writeln(arr[i])
if(arr[i].pageItems.length === 0){
arr[i].remove()
}else{
$.writeln(arr[i])
continue
}
}
} function addLayer(name, rgbColors){
if (rgbColors === undefined){rgbColors = [255, 0, 255]}
var cont = true;
function change() {
cont = !cont;
}
for(i = 0; i < app.activeDocument.layers.length; i++){
if(app.activeDocument.layers[i].name == name){
change();
}
}
if (cont == true) {
var newColor = new RGBColor();
newColor.red = rgbColors[0];
newColor.green = rgbColors[1];
newColor.blue = rgbColors[2];
var newLayer = app.activeDocument.layers.add();
newLayer.name = name;
newLayer.color = newColor;
}
app.activeDocument.layers[name].visibile = true
app.activeDocument.layers[name].locked = false
app.activeDocument.activeLayer = app.activeDocument.layers.getByName(name);
} Also using this function from another file
... View more
‎Aug 13, 2020
04:33 PM
As a test, I added a PMS spot color to a Library and then, in a new, empty document, I selected the color in the Library and chose "Add to Swatches" from the Library palette menu. The color appeared in the swatches palette, but the name was gone. Weird. Sorry I couldn't help. At this stage the Library doesn't seem to be directly accessible by scripts.
... View more
‎Aug 12, 2020
08:09 PM
3 Upvotes
Hi robsmith01, This is one way: var compoundPathItems = app.activeDocument.compoundPathItems;
for (var i = 0; i < compoundPathItems.length; i++) {
compoundPathItems[i].name = "found you, number " + i;
} Just put your own string in place of "found you, number " + i.
... View more
‎Aug 11, 2020
05:44 PM
1 Upvote
Signed-in users now have an option to change their own screen names on the Community.
How to change your screen name?
Click the user avatar on the header banner => select "My Profile" from the drop down => Click the edit icon on the top right corner of your current screen name => Enter your new name and submit!
... View more
‎Jul 21, 2020
11:23 PM
Hi, here is an example of a fairly normal svg generated straight from Illustrator. Note I've used a symbol for the arrowhead, assuming that you'd re-use it many times in the same file. Only tested in Chrome and Safari on MacOS. See "Save As..." settings below, too. My apologies if this misses the point, but it is an alternative way. Regards, Mark <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="svgDoc" xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 663.3 484.7"
style="enable-background:new 0 0 663.3 484.7;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#FF0000;stroke-width:0.5;stroke-miterlimit:2;}
.st1{fill:none;stroke:#FF0000;stroke-width:0.5;}
</style>
<symbol id="arrowhead-01" viewBox="-2.6 -2.7 5.2 5.4">
<path class="st0" d="M-2.5,2.5l5-2.5l-5-2.5"/>
</symbol>
<use xlink:href="#arrowhead-01" width="5.2" height="5.4" x="-2.6" y="-2.7" transform="matrix(1 0 0 -1 263.1581 202.5013)" style="overflow:visible;"/>
<path class="st1" d="M265.7,202.5c-24.7-1.7-29.8,17.1-29.8,32.9"/>
</svg>
... View more
‎Jul 17, 2020
09:00 AM
Hi there,
Thanks for reaching out. I hope you found your answer. We'd appreciate if you can mark the appropriate response correct. If you used any other method, you can share it with us. It'll help other users with similar concern.
Let us know if you have still have any concern, we'll be happy to help.
Regards,
Ashutosh
... View more
‎Jul 16, 2020
10:26 AM
Just to show that in certain situations one can also do it without using a script, here is the Pathfinder approach for filled (unrotated) paths.
https://drive.google.com/file/d/1GXCmSgXXSgrc26z779LsiaROqqlEM2db/view?usp=sharing
Instructions:
- Select all - In the Graphic Styles palette apply the style Subtract_10_mm_top_bottom - Object > Expand Appearance
In this case the style subtracts 10 mm (top) and 10 mm (bottom), but you can easily modify the settings in the Appearance palette. Plus, you can have different subtract settings (sizes) at the bottom and the top of the paths.
As already mentioned, it is not as versatile as the scripting approach, but at least it is really subtracting things, not just resizing 🙂
... View more
‎Jul 14, 2020
07:45 AM
Thanks, I did see this from an earlier post but I just can't seem to get it to work.
... View more
‎Jul 14, 2020
12:56 AM
did you try the script I posted?
... View more
‎Jul 12, 2020
02:59 PM
1 Upvote
Thanks Carlos, that one looks like it has a lot of options. For convenience, here's the link to the repo: https://github.com/Inventsable/Outliner (just in case it's been updated since it was posted).
... View more
‎Jul 10, 2020
09:22 PM
1 Upvote
Also note, if you are using Visual Studio Code and ExtendScript Debugger, you need "//@include", eg. //@include "../lib/otherFile.js" I don't think it matters which extension you use. I've not had trouble with .js and .jsx anyway. Using .jsxinc just seemed unnecessary so I gave it up. Mark
... View more
‎Jul 08, 2020
12:10 PM
Hi @ellipirelli,
there is no need to loop through all group pageItems. Use the class CompoundPathItems instead.
Here an example with much more better performance:
var aDoc = app.activeDocument;
var cPI = aDoc.layers["Norm"].groupItems[0].compoundPathItems;
var cPIlen = cPI.length;
for (var i = 0; i < cPIlen; i++) {
cPI[i].pathItems[0].filled = true;
cPI[i].pathItems[0].fillColor = aDoc.swatches[8].color;
}
If that works for you
have fun
😉
... View more
‎Jul 07, 2020
07:15 PM
1 Upvote
It was useful to fix my script. Thanks!
... View more
‎Jul 05, 2020
12:28 PM
That's correct. You got it. 🙂
... View more
‎Jun 30, 2020
02:41 PM
Very glad it helped! Thanks for letting me know. 🙂
... View more
‎Jun 29, 2020
06:57 PM
It was very useful! Thanks!
... View more
‎Jun 26, 2020
04:08 AM
It seems if a script changes the artboard, the origin doesn't move, but if you manually resize the artboard, the origin moves with it... is that correct?
... View more
‎Jun 18, 2020
04:20 PM
1 Upvote
Wow! Horrible to have to work around, but amazing! 🙂
... View more
‎Jun 09, 2020
02:28 AM
Sorry, I myself never tried that with the SDK.
... View more
‎Jun 08, 2020
08:07 AM
Welcome back. I was worried we all scared you away. 😜
By all means come on back any time with any questions you have. Let us know what you're working on and we'll find a way to help. 😃
... View more
‎Jun 04, 2020
06:37 PM
I can't THNK YOU enough! That was super kind of you to do and it is much appreciated!
... View more
‎Jun 04, 2020
04:42 PM
1 Upvote
Document has a method that could help: app.activeDocument.selectObjectsOnActiveArtboard() Be careful though as it will select any object that insects with the active artboard even if (to our eyes) it properly belongs to another artboard. Also Artboards has a method to use to set the active artboard: artboards.setActiveArtboardIndex(index)
... View more
‎Jun 03, 2020
11:35 PM
1 Upvote
Well, I need to look in to this and currently my laptop is completeley dead and due to this, it will be difficult to tell you because all related documentations and everything is on my laptop. I will confirm and get back to you soon.
... View more
‎Jun 01, 2020
01:08 PM
1 Upvote
Yes, definitely it also gives 0,0,0 as RGB in the beginning. Thank you.
... View more
- « Previous
- Next »