m1b
Community Expert
m1b
Community Expert
Activity
‎Oct 01, 2020
02:35 PM
Hi mystery_sk, it's great that you've had a go at cobbling together from scripts, but it's hard to know where the blockage is without more information. Perhaps you could explain the part of your frankenstein script that fails? Or the incorrect results you're getting.
... View more
‎Oct 01, 2020
05:16 AM
Hi, This is how I do it. var ab = app.activeDocument.artboards[0];
var l = 0, t = 0, r = 100, b = -100;
ab.artboardRect = [l,t,r,b]; – Mark
... View more
‎Sep 29, 2020
11:17 PM
I'd be interested to hear what you discover! Sorry I couldn't help though. Your existing method is the way I've done it previously. Mark
... View more
‎Sep 16, 2020
05:47 PM
2 Upvotes
Hi femkeblanco, In Visual Studio Code I made a script which invoked the debugger: debugger; Then ran the script using the ExtendScript Debugger. By the way, this was my launch configuration: {
"type": "extendscript-debug",
"request": "launch",
"name": "Debug current file",
"program": "${file}",
"targetSpecifier": "illustrator-24.064"
} As the script runs, Illustrator is activated but, when the debugger is invoked, Visual Studio Code is re-activated and the script is paused. This is where you would be stepping through the debugging process, but that isn't what I needed this time. I looked in the debug pane under 'variables' and navigated to 'local/app/activeDocument', and then I looked through the list of properties of the active document and found 'scaleFactor'. Bingo! Hope that works for you. - Mark
... View more
‎Sep 10, 2020
02:36 PM
I don't know how to do that. If your script first opens a ScriptUI window you might have a better chance. See https://creativepro.com/files/kahrel/indesign/scriptui.html section on "Listening to the keyboard". Maybe? Sounds like it isn't quite what you want. I wondered if you could check for option (.altKey) during a scriptUI window.onShow event?
... View more
‎Sep 08, 2020
04:16 PM
I didn't know that. Thanks! 🙂
... View more
‎Sep 06, 2020
05:52 PM
Quick fix (not the most elegant!) is to comment out this line: if (optionsDlg.show() == 1) I hope I've understood your intent here. By commenting out the above line, it stops the dialog window from coming up at all and the rest of the script just uses the values you've put in as defaults.
... 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 28, 2020
01:51 AM
1 Upvote
Oh, oops. I understand now. Sorry, I jumped to the conclusion. 🙂 There is a cool technique you can do with rotating, not sure if it's applicable in your case, but if you can work out the point you wish to rotate around, you can then translate the item so that that point is at the "document origin" (the 0, 0 point), rotate it around (from memory, please check) Transformation.DOCUMENTORIGIN and then translate it back by the same amount you moved it firstly. In this way you can rotate around an arbitrary point on the artboard. Another idea is to have a look at Execute Menu Command.
... View more
‎Aug 26, 2020
07:42 PM
1 Upvote
Hi Maple_Stirrup, you can perform transformations on pageItems using those item's "methods" which do something to the item. For example, a PathItem has a these methods. So, for example, the rotate method looks like this: yourPathItem.rotate(angle[,changePositions][,changeFillPatterns][,changeFillGradients][,changeStrokePattern][,rotateAbout]) Here's how you'd use it: // grab the first path item in the document
var myPathItem = app.activeDocument.pathItems[0];
// rotate it by 45 degrees
myPathItem.rotate(45);
// rotate it by another 45 degrees from the bottom left
myPathItem.rotate(45, false, false, false, false, Transformation.BOTTOMLEFT); The second version includes all the optional parameters. Parameters are the equivalent of the "fields" you enter when you rotate via the GUI. The 45 parameter is the rotation angle. Mark
... View more
‎Aug 19, 2020
07:39 PM
You're welcome!
... View more
‎Aug 19, 2020
02:55 PM
3 Upvotes
Hi, use "targetSpecifier". This is what I use for a simple case of "debug the file I'm editing right now": {
"type": "extendscript-debug",
"request": "launch",
"name": "Debug current file",
"program": "${file}",
"targetSpecifier": "illustrator-24.064"
} You can find the version of Illustrator by doing app.version, and taking the main version number (24 for me) and adding 0.64 for 64 bit. I haven't done this with many versions, and only on Mac, so I don't know how robust this method is.
... View more
‎Aug 17, 2020
04:36 PM
Ah! Thanks.
... 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 16, 2020
10:14 PM
Yeah, that's what I found too. I also tried it all wrapped in an object and that didn't help either. I'm really curious! It seems to be getting slower linearly, but I haven't graphed the times. Closing and reopening the document doesn't help.
... View more
‎Aug 16, 2020
09:43 PM
Hi, I'm not an expert at this, and your code looks fine to me, but if you have time to experiment, it might help to try structuring your script as a Self Invoking Function. This answer gives a quick overview. The idea is to tidy up the scope of the variables, so there shouldn't be anything left in memory after the function has been executed. The second execution should leave memory as pristine as the first. Well, that's the theory. EDIT: I was curious, so I just tried structuring your code as a self-invoking function and it didn't help. Each run gets slower, as you report. Curious! I'll wait for an answer, too. 🙂
... View more
‎Aug 16, 2020
03:29 PM
I don't have an answer, but I'm curious: what do the redraw() commands fix? I've mainly used them to either update the UI or to provide intermediate levels of undo.
... View more
‎Aug 16, 2020
03:23 PM
rutgers_camden, is that normal behaviour (that "Illustrator currently renders the preview to highlight the selection, the same as when the user is manually selecting the object")? In my scripts the UI doesn't seem to be updated during a script unless I explicitly call app.redraw(). Are you calling redraw? CarlosCanto, that's interesting! I've never thought to do that to speed up a script, again, because I've never noticed the UI updating during execution. On the contrary, I've sometimes inserted app.redraw() to give a visual update or to provide several undos vs one undo for the whole script action. As a side note: in my experience, setting the selection is bizarrely *slow*. For example, a script that deletes every 2nd pageItem will be way faster than a script that selects every 2nd pageItem. Have you guys found that? So, rutgers_camden is there a way you could get your script working without the selecting part?
... View more
‎Aug 16, 2020
01:29 AM
This might not be what you want, but have you looked at userInteractionLevel? app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS (The other UserInteractionLevel is .DISPLAYALERTS)
... View more
‎Aug 13, 2020
06:00 PM
Without seeing your code, I don't know what's going on, BUT I think there's a good chance the problem is caused by the rearrangement of the document messing up your references to the pageItems. To test, you could try a few things. First, your "array" might be "an array like object", and not a vanilla Array. From memory, you can do var newArray = oldArray.slice() to make a normal array. That might work. Sorry I can't test now so it's just from my poor memory. Or maybe you could get new references to your objects after moving them or deleting layers? Also, working with arrays in reverse order can often work as it might not mess up the references (depending on what you're doing). For example, deleting items starting at the end of the array won't change the indices of the unprocessed items.
... 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 04, 2020
02:29 PM
I don't think it's possible the way you would like. However, is there any scope for restructuring your script to have all the js logic happening on the js side, even if it means lots of calls to functions on the jsx side?
... 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 16, 2020
01:37 AM
Nice! Does the selection[i].scaleAbout = Transformation.CENTER mean anything special? I normally use just the constant on it's own as the parameter.
... View more
‎Jul 13, 2020
03:44 PM
I actually couldn't find a way to do this with a script, but hopefully someone else will know. But just checking that you know you can right-click on the ruler to change units?
... View more
‎Jul 13, 2020
03:24 PM
It's possible that the Chinese name of [Registration] mismatching with your computer's language is a problem, but it could be something else. In my experience when I'm concerned about a possible file corruption I'd copy the contents out into another file. (Helps to choose "Paste Remembers Layers" in the Layers palette menu.) If the new file is still glitchy, then something you copied was the problem.
... 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 12, 2020
02:57 AM
1 Upvote
Check out jooHandlesToGeometry.jsx from https://bitbucket.org/joojaa/jooillustratorscripts/ Mark
... 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