RobOctopus
Participant
RobOctopus
Participant
Activity
‎Feb 13, 2025
07:31 AM
The key for me was using bridge talk to work with my current code: (function() { // Get the script directory var scriptFile = new File($.fileName); var scriptDir = scriptFile.parent.fsName.replace(/\\/g, '/'); // Create the BridgeTalk message var bt = new BridgeTalk(); bt.target = "illustrator"; // Set the current directory for includes bt.body = "$.evalFile('" + scriptDir + "/TemplateModifier.jsx');"; bt.onError = function(err) { alert("Error launching Template Modifier. Please try again."); }; bt.send(); })(); This code also was significant help: //@target illustrator //@targetengine LauncherEngine //@strict on (function () { // 1) Reference the folder where this script resides: // This helps us find the other scripts in the same folder. // (You can change these paths as needed.) var thisFile = new File($.fileName); var thisFolder = thisFile.parent; // the folder containing Launcher.jsx // 2) Build a small helper to launch an external .jsx script // via BridgeTalk (so the palette remains open). function runScript(fileName) { var scriptFile = new File(thisFolder + "/" + fileName); if (!scriptFile.exists) { alert("Cannot find: " + fileName); return; } // Read the script's text scriptFile.open("r"); var code = scriptFile.read(); scriptFile.close(); // Build a BridgeTalk message that targets Illustrator var bt = new BridgeTalk(); bt.target = "illustrator"; bt.body = code; // Directly eval the script's contents bt.onError = function(err) { alert("Error running " + fileName + ":\n" + err.body); }; bt.send(); // run asynchronously } // 3) Create the "Launcher" palette window // • "palette" type keeps it modeless, so you can use Illustrator freely // • We used `@targetengine LauncherEngine` so it remains open. var win = new Window("palette", "Launcher", undefined, { resizeable: true, closeButton: true }); win.orientation = "column"; win.alignChildren = ["fill", "top"]; win.margins = 10; // 4) Add three buttons for the three scripts var btn1 = win.add("button", undefined, "Create New Die"); btn1.onClick = function() { runScript("NewDieWIP.jsx"); }; var btn2 = win.add("button", undefined, "Run Script 2"); btn2.onClick = function() { runScript("myScript2.jsx"); // runs myScript2.jsx }; var btn3 = win.add("button", undefined, "Run Script 3"); btn3.onClick = function() { runScript("myScript3.jsx"); // runs myScript3.jsx }; // 5) Show the palette. It will stay open, letting you: // • Use these buttons any time // • Continue drawing on the artboard and using tools win.show(); })();
... View more
‎Jan 29, 2025
07:51 AM
1 Upvote
Hi @Jaime33551855kfcj - Please try the following
function applyShearTransform(value) {
actionString = [
'/version 3',
'/name [ 5',
' 5365742031',
']',
'/isOpen 1',
'/actionCount 1',
'/action-1 {',
' /name [ 5',
' 5368656172',
' ]',
' /keyIndex 0',
' /colorIndex 0',
' /isOpen 1',
' /eventCount 1',
' /event-1 {',
' /useRulersIn1stQuadrant 0',
' /internalName (ai_plugin_transformPalette)',
' /localizedName [ 15',
' 5472616e73666f726d2050616e656c',
' ]',
' /isOpen 1',
' /isOn 1',
' /hasDialog 0',
' /parameterCount 2',
' /parameter-1 {',
' /key 1954115685',
' /showInPalette 4294967295',
' /type (enumerated)',
' /name [ 6',
' 53686561723a',
' ]',
' /value 4',
' }',
' /parameter-2 {',
' /key 1986096245',
' /showInPalette 4294967295',
' /type (unit real)',
' /value ' + value.toFixed(1),
' /unit 591490663',
' }',
' }',
'}'
].join('\n')
var f = new File(Folder.desktop + "/shear.aia");
if (f.exists) {
f.remove();
}
f.open('w')
f.write(actionString)
f.close()
app.loadAction(f)
app.doScript('Shear', 'Set 1')
app.unloadAction('Set 1', '');
f.remove();
}
applyShearTransform(7);
... View more
‎Jan 23, 2025
10:31 AM
a lot of the sample scripts provided via the adobe application don't do anything spectacular but rather show functionality via extendscript. Its up to you to extrapolate how the script is being demonstrated and use it in a different way. opening the file to edit it would show you via the comments and the small amount of code how the desired result is achieved and what you would need to change to benefit your needs.
... View more
‎Jan 20, 2025
06:02 PM
when editting the contents of text via scripting you need to use insertion points to add text to maintain text styling. simply altering the contents will cause all of the contents to be reformatted to the same format as the first character.
... View more
‎Jan 10, 2025
01:20 AM
Trying to use data sets to link data but my template has two cards on a printable sheet. 2 - 5x7 sheets printed on a letter size paper. can I have two duplicate data sets on a single page or format to print/save as two on a single page? What would be best to do this?
... View more
‎Dec 16, 2024
06:14 AM
1 Upvote
Everything RobOctopus said, this is totally doable. I created a load/preflight script for my group that detects the art on a client proof, replaces all fpo images with high-res links, adds bleed, checks rich blacks, and scales from letter size proofs to production 1:12 or 1:24 scale billboards in over 216 unique sizesk on over 14substrates... all while checking all the usual trap/overprint/etc issues that production art needs for each type of material and press requirements. We tripled our work capacity and reduced prepress time investment by 75% in three months with much of what you are looking to do. My advice for you is that start by organizing your tasks, put them in the order you wish them to be run and work on each section independently until you're happy with each result... then afterwards combine into the larger "finished" script for deployment. It will make your troubleshooting and dev cycle much easier to manage, and enable you to focus on specific roadblocks you may encounter. It will also give you a "toolbox" of mini scripts that you can use to achieve specific tasks without running the entire script only.
... View more
‎Dec 06, 2024
04:36 PM
My brain is the same as yours, I swear they used to append when copying and pasting, I have the same problem with a job that has a ton of them, I've popped the question on another forum, check boxes still do it!
... View more
‎Nov 26, 2024
12:42 PM
1 Upvote
A simpler way to achieve this is to examine item.editable.
... View more
‎Nov 15, 2024
01:55 PM
Leaving a comment to let you know that this solution helped me out in a big way! Thank you!
... View more
‎Nov 08, 2024
10:09 PM
I spent some time learning about the regex search pattern options once RobOctopus pointed me in the right direction. At some point I tried the 1,2 but I had it as [1,2] and never got it to resolve. The best I came up with was (/^XX T\d+$/g) but now with your help I can see I can use the ( /$) to include the space at the end ... and much more importantly limit the pattern to only two digits. Much appreciated.
... View more
‎Oct 24, 2024
01:23 PM
Thank you, that option using a Rect works for me,
... View more
‎Oct 16, 2024
09:07 PM
Hi, Connection issue: When using ScriptUI palette windows, you may sometimes be unable to access the active document in Illustrator. This is because the script window loses its connection to the active document. See the following discussion. Is ScriptUI in Illustrator broken? - Adobe Community - 13640854
... View more
‎Oct 09, 2024
12:28 PM
I tried it with that additional line and it works now, thank you for your help!
... View more
‎Oct 03, 2024
10:01 AM
1 Upvote
good approach, but change PANTONE 288 C to PANTONE 195 C or vice versa, also there no need to declare second _pantoneColor, assinning is enough
... View more
‎Sep 09, 2024
06:27 PM
sorry for posting in wrong forum
... View more
‎Aug 05, 2024
11:10 AM
1 Upvote
@jduncan great tip! Thank you so much! from the design perspectiv this is not beautiful but if I'll use the txt above as column title this will do the job 😉
... View more
‎Jul 09, 2024
08:09 PM
As @Robert38512781pn4f mentioned, they may be better ways to do this. But since I had a function already that does most of this, I will share this script, too.
- Mark
/**
* @file Make Numbered Text Frames On Artboards.js
*
* Makes numbered text frames on available artboards.
* Adjust the constants START, END, ITEMS_PER_ARTBOARD,
* GAP_PTS and TEXT_SIZE_PTS.
*
* @author m1b
* @version 2024-07-10
* @discussion https://community.adobe.com/t5/illustrator-discussions/need-help-with-making-308-different-numbered-text-boxes/m-p/14728931
*/
(function () {
const START = 1,
END = 308,
ITEMS_PER_ARTBOARD = 30;
const GAP_PTS = 60,
TEXT_SIZE_PTS = 30;
var doc = app.activeDocument,
total = END - START,
len = Math.ceil(total / ITEMS_PER_ARTBOARD);
if (doc.artboards.length < len)
return alert('Not enough artboards to fit ' + ITEMS_PER_ARTBOARD + ' numbers per artboard.\n(' + doc.artboards.length + ' available, ' + len + ' required).');
for (var i = 0, ab, bounds, remainder = total + 1, counter, frame, frames; i < len; i++) {
frames = [];
counter = Math.min(ITEMS_PER_ARTBOARD, remainder);
while (counter--) {
frame = doc.textFrames.add();
frame.contents = total - (--remainder) + START;
frame.textRange.size = TEXT_SIZE_PTS;
frames.push(frame);
}
ab = doc.artboards[i];
bounds = ab.artboardRect;
arrangeItems({
items: frames,
gap: GAP_PTS,
maxWidth: bounds[2] - bounds[0],
origin: [bounds[0], bounds[1]],
});
if (remainder < START)
break;
}
})();
/**
* Positions page items in a simple L-R, T-B grid,
* given `maxWidth`, with `gap` between each item.
* The `lineHeight` variable is the largest height
* in a given row.
* @author m1b
* @version 2023-11-01
* @param {Object} options
* @param {Array<Number>} options.origin - the origin [x,y] of the top-left of the grid.
* @param {Array<PageItem>} options.items - the items to position.
* @param {Number} [options.maxWidth] - the maximum width of the grid area, in points (default: no maximum).
* @param {Number} [options.gap] - the gap between items (default: 0).
*/
arrangeItems = function arrangeItems(options) {
options = options || {};
var origin = options.origin,
items = options.items,
maxWidth = options.maxWidth || Infinity,
gap = options.gap || 0;
var x = 0,
y = 0,
lineHeight = 0;
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (x + item.width > maxWidth) {
// move down
x = 0;
y -= (lineHeight || item.height) + gap;
lineHeight = 0;
}
// position the item
items[i].position = [origin[0] + x, origin[1] + y];
// move right
x += item.width + gap;
if (item.height > lineHeight)
lineHeight = item.height;
}
};
... View more
‎Jun 05, 2024
11:44 AM
@RobOctopus, yep this works but still leaves a hidden extra stroke in the appearance panel that bugs me. I was hoping for a native way to accomplish this but I'm beginning to think there isn't one. As for turning off the visibility in the actual appearance, it is something I have seen on occasion and something I do from time to time, especially with prebuilt styles. For example, in the attached image I have a prebuilt style for the name (top object), but I can easily turn off the pink accents and inner gradient to quickly achieve an alternate look without having to keep two separate styles in sync.   Thanks for thr suggestion!
... View more
‎May 28, 2024
10:55 AM
Welp you did tell me that already. And sonofagun, it worked! Thanks for all the help!
... View more
‎May 23, 2024
12:38 PM
No Problem @Aidan_C . Unfortunately, aligning stroke is really goofy via scripting, but doable. Add the following to the previous code. /*the original code i sent had layers being created around line 23/24 add this there*/
var BackgroundRectangle = FindLayerCreate(app.activeDocument, "WHITE RECTANGLE")
/*previous code things here*/
/*then after the circles are made add this
it will create a rectangle on the background rectangle layer we make earlier
then we make sure the stroke is white, the width is equal to the circle sizes, and that there isnt a fill. then we call the align stroke function and finally move it to the bottom of the stack as a redudancy*/
var WhiteRectangle = BackgroundRectangle.pathItems.rectangle(ATop+Bleed,ALeft-Bleed, AWidth+(Bleed*2), -(AHeight-(Bleed*2)))
WhiteRectangle.stroked = true
WhiteRectangle.strokeWidth = CircleWidthHeight
WhiteRectangle.strokeColor = new CMYKColor();
WhiteRectangle.filled = false
WhiteRectangle.fillColor = new NoColor();
AlignStroke(WhiteRectangle, 1)
BackgroundRectangle.move(app.activeDocument,ElementPlacement.PLACEATEND)
/* somewhere at the bottom of the code, copy/paste this function does some goofy things to align the stroke by creating an action to do it for us and then deleting the action */
/**
* Will change the alignment of a stroked path.
* @param {Object} FrameToAlign - PathItem to edit
* @param {String|Number} AlignNumber - 0=Center, 1=Inside, 2=Outside
*/
function AlignStroke(FrameToAlign, AlignNumber){
/*
need to grab the previous stroke join and cap as they are overwritten for some reason.
will reset them back to their previous state at the end of the function
*/
var PreviousJoin = FrameToAlign.strokeJoin
var PreviousCap = FrameToAlign.strokeCap
switch(AlignNumber){
case "0":
case 0:
var AlignInsert = [
'/name [ 6',
'43656e746572',
']',
'/value 0']
break;
case "1":
case 1:
var AlignInsert = [
'/name [ 6',
'496e73696465',
']',
'/value 1']
break;
case "2":
case 2:
var AlignInsert = [
'/name [ 7',
'4f757473696465',
']',
'/value 2']
break
}
var ActionString = [
'/version 3',
'/name [ 14',
'5374726f6b65416c69676e536574',
']',
'/isOpen 1',
'/actionCount 1',
'/action-1 {',
'/name [ 17',
'5374726f6b65416c69676e416374696f6e',
']',
'/keyIndex 0',
'/colorIndex 0',
'/isOpen 1',
'/eventCount 1',
'/event-1 {',
'/useRulersIn1stQuadrant 0',
'/internalName (ai_plugin_setStroke)',
'/localizedName [ 10',
'536574205374726f6b65',
']',
'/isOpen 1',
'/isOn 1',
'/hasDialog 0',
'/parameterCount 1',
'/parameter-1 {',
'/key 1634494318',
'/showInPalette 4294967295',
'/type (enumerated)'].concat(AlignInsert,
'}',
'}',
'}').join("\n")
var f = File(Folder.desktop+"/StrokeAlignment.aia");
f.open('w');
f.write(ActionString);
f.close();
app.executeMenuCommand("deselectall")
FrameToAlign.selected = true;
app.loadAction(f);
app.doScript('StrokeAlignAction', 'StrokeAlignSet');
app.unloadAction('StrokeAlignSet', '');
f.remove();
FrameToAlign.strokeJoin = PreviousJoin
FrameToAlign.strokeCap = PreviousCap
}
... View more
‎May 20, 2024
07:34 AM
thanks for a detailed answer, RobOctobus it cleared my confusion between menu command and that setting - I was clicking menu command and reading setting to no avail, never tried to set set the setting by code. ..meanwhile menu command was modifyng actual text
... View more
‎Apr 12, 2024
09:53 AM
so you want to take the information from 1 file. hold it into a script and recreate on another machine. This, i'm sure makes copy paste information unusable. I would think you would have an easier time getting the path of the object and contents (size, leading, etc) and then recreating that way psuedo code
get text frames
for each text frame
get all path points along their text path (to recreate the path items, allows for irregular shapes)
get the contents of the text frame
for each character house loop through and save the size,leading and other pertinent styling options, along with font
all of the above information would be housed in some array format
new doc loop through array
create path item from coordinates
add text contents to path
loop through all character styling and apply correct styles to each
... View more
‎Apr 08, 2024
05:15 PM
Ah, yes I should have mentioned that. If there is no return value from the bt.body, then no callback get's triggered. Glad you sorted it out!
... View more
‎Apr 06, 2024
02:04 AM
Thank you very much. Your solution wasn't exactly what I was looking for, but I suspect it's because I didn't explain my needs well enough. Regardless, I was able to figure out how the coordinate system works now using your simplified approach, and I managed to get it working for my use-case. I'll paste the code below for future reference if someone needs something like this. Thank you again! // Top-left corner
drawMark(x1 + bleedPoints, y1, lengthPoints, true); // Vertical
drawMark(x1 - lengthPoints, y1 - bleedPoints, lengthPoints, false); // Horizontal
// Top-right corner
drawMark(x2 - bleedPoints, y1, lengthPoints, true); // Vertical
drawMark(x2, y1 - bleedPoints, lengthPoints, false); // Horizontal
// Bottom-left corner
drawMark(x1 + bleedPoints, y2 - lengthPoints, lengthPoints, true); // Vertical
drawMark(x1 - lengthPoints, y2 + bleedPoints, lengthPoints, false); // Horizontal
// Bottom-right corner
drawMark(x2 - bleedPoints, y2 - lengthPoints, lengthPoints, true); // Vertical
drawMark(x2, y2 + bleedPoints, lengthPoints, false); // Horizontal
... View more
‎Apr 03, 2024
08:37 AM
Rob, thank you very much for sharing the above code here, I followed the above steps i got below errors, can you please help
... View more
‎Apr 03, 2024
08:14 AM
1 Upvote
alternative approach if you dont want to keep the 2.83... constant anytime you want to use it. There is a built in function to create and convert units UnitValue(Value,Unit) This will create a value in the specified unit. so you can do UnitValue(8,"mm") and it would be an 8 mm value. the problem specifically with Illustrator is all values are point based. There's another function with UnitValue to convert UV.as(conversion) so you can do UnitValue(8,"mm").as("pt") and it will convert the 8 mm to points for use. so the above could be var newWidth = width + UnitValue(8,"mm").as("pt") more documentation here https://extendscript.docsforadobe.dev/extendscript-tools-features/specifying-measurement-values.html once I found this, I started using this method over having to keep the units I needed as a global value or put into each function. Cheers
... View more
‎Mar 29, 2024
07:37 PM
Thank you so much @RobOctopus , its working as expect
... View more
‎Mar 27, 2024
04:24 PM
1 Upvote
Thanks @RobOctopus that's great info!
- Mark
... View more
‎Mar 21, 2024
09:05 PM
Hi Mark, Thanks for your support. Now I get the kerning values.
... View more
‎Mar 08, 2024
11:56 PM
1 Upvote
Great! Hope your project goes well.
... View more