• I want to thank all the members that have upgraded your accounts. I truly appreciate your support of the site monetarily. Supporting the site keeps this site up and running as a lot of work daily goes on behind the scenes. Click to Support Signs101 ...

Looking for any script writers

myront

Dammit, make it faster!!
I have a free script that I found and would like to modify the code. I messed around a bit but can't seem to get what I'm after. I'm more familiar with vbs.
Any "scripters" here.
 

netsol

Premium Subscriber
my unix (sco 5 & redhat 7 +8) programmer tried an experiment the other day and asked copilot to
write him a couple scripts. SURPRISINGLY, he found that he only had to "touch up" the finished
product a bit to make it usable
 

WildWestDesigns

Active Member
my unix (sco 5 & redhat 7 +8) programmer tried an experiment the other day and asked copilot to
write him a couple scripts. SURPRISINGLY, he found that he only had to "touch up" the finished
product a bit to make it usable
That's because of MS and their being behind TS as well as Co-Pilot I would imagine. But that's me speculating.
 

myront

Dammit, make it faster!!
Ok, been working with Copilot for a few hours. Works great but cannot, for the life of me, get the height of my created rectangle to size height properly. Seems no matter what mod I or Copilot does to the calculation, either it ends with doing the opposite or stays the same.
 

myront

Dammit, make it faster!!
What generally, or specifically, are you trying to do? Is this in Illustrator?
Yes, illustrator.
Think I got it worked out. Bounding box of text is different than if the text is outlined. So script to outline text first then do the rest.

WeedLines.jsx

// Check if there are any selected objects
if (app.selection.length > 0) {
// Group the selection first
app.executeMenuCommand("group");
app.executeMenuCommand("outline");

var selectedItems = app.selection;
var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;

// Calculate the combined bounding box of the grouped shapes as a whole
for (var i = 0; i < selectedItems.length; i++) {
var item = selectedItems;
var bounds = item.visibleBounds;
minX = Math.min(minX, bounds[0]);
minY = Math.min(minY, bounds[1]);
maxX = Math.max(maxX, bounds[2]);
maxY = Math.max(maxY, bounds[3]);
}

// Increase the bounding box width by 0.1 inch and height by 0.1 inch (converted to points, where 1 inch = 72 points)
var widthIncrement = 0.1 * 72;
var heightIncrement = .1 - 72 / 2; // Correct height increment

minX -= widthIncrement / 2;
maxX += widthIncrement / 2;
minY -= heightIncrement /2; // Decrease minY to extend downward
maxY += heightIncrement /2; // Increase maxY to extend upward

// Create a new layer for the rectangle and lines
var layer = app.activeDocument.layers.add();
layer.name = "Rectangle and Lines";

// Create the rectangle with increased dimensions
var rectangle = layer.pathItems.rectangle(maxY, minX, maxX - minX, maxY - minY);
rectangle.filled = false; // No fill
rectangle.stroked = true;
rectangle.strokeColor = app.activeDocument.swatches.getByName("Black").color;

// Create the vertical line segment
var verticalLine = layer.pathItems.add();
verticalLine.setEntirePath([[minX + (maxX - minX) / 2, maxY], [minX + (maxX - minX) / 2, minY]]);
verticalLine.stroked = true;
verticalLine.strokeColor = app.activeDocument.swatches.getByName("Black").color;

// Create the horizontal line segment
var horizontalLine = layer.pathItems.add();
horizontalLine.setEntirePath([[minX, minY + (maxY - minY) / 2], [maxX, minY + (maxY - minY) / 2]]);
horizontalLine.stroked = true;
horizontalLine.strokeColor = app.activeDocument.swatches.getByName("Black").color;

// Ungroup the selection at the end
app.executeMenuCommand("ungroup");

// Deselect everything
app.selection = null;

}
 

ikarasu

Active Member
Use chatgtp. Feed it the code, tell it what it's doing wrong and it'll likely fix it ... I find it works better than co pilot.


AI is great for code... IF you can read the code.
 

ikarasu

Active Member
Yes, illustrator.
Think I got it worked out. Bounding box of text is different than if the text is outlined. So script to outline text first then do the rest.

WeedLines.jsx

// Check if there are any selected objects
if (app.selection.length > 0) {
// Group the selection first
app.executeMenuCommand("group");
app.executeMenuCommand("outline");

var selectedItems = app.selection;
var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;

// Calculate the combined bounding box of the grouped shapes as a whole
for (var i = 0; i < selectedItems.length; i++) {
var item = selectedItems;
var bounds = item.visibleBounds;
minX = Math.min(minX, bounds[0]);
minY = Math.min(minY, bounds[1]);
maxX = Math.max(maxX, bounds[2]);
maxY = Math.max(maxY, bounds[3]);
}

// Increase the bounding box width by 0.1 inch and height by 0.1 inch (converted to points, where 1 inch = 72 points)
var widthIncrement = 0.1 * 72;
var heightIncrement = .1 - 72 / 2; // Correct height increment

minX -= widthIncrement / 2;
maxX += widthIncrement / 2;
minY -= heightIncrement /2; // Decrease minY to extend downward
maxY += heightIncrement /2; // Increase maxY to extend upward

// Create a new layer for the rectangle and lines
var layer = app.activeDocument.layers.add();
layer.name = "Rectangle and Lines";

// Create the rectangle with increased dimensions
var rectangle = layer.pathItems.rectangle(maxY, minX, maxX - minX, maxY - minY);
rectangle.filled = false; // No fill
rectangle.stroked = true;
rectangle.strokeColor = app.activeDocument.swatches.getByName("Black").color;

// Create the vertical line segment
var verticalLine = layer.pathItems.add();
verticalLine.setEntirePath([[minX + (maxX - minX) / 2, maxY], [minX + (maxX - minX) / 2, minY]]);
verticalLine.stroked = true;
verticalLine.strokeColor = app.activeDocument.swatches.getByName("Black").color;

// Create the horizontal line segment
var horizontalLine = layer.pathItems.add();
horizontalLine.setEntirePath([[minX, minY + (maxY - minY) / 2], [maxX, minY + (maxY - minY) / 2]]);
horizontalLine.stroked = true;
horizontalLine.strokeColor = app.activeDocument.swatches.getByName("Black").color;

// Ungroup the selection at the end
app.executeMenuCommand("ungroup");

// Deselect everything
app.selection = null;

}
Are you just selecting a text, outlining it and creating a bounding box .1" past to make weeding easier?

Is it adding additional vertical / horizontal lines based on a specific criteria?
 

WildWestDesigns

Active Member
AI is great for code... IF you can read the code.
While AI has it's issue that make it not quite the shiny best thing out there, it depends on the language as well. JS/TS are the most written about (and I do believe JS, maybe not TS, is the most popular language out there, it swaps with Python some years(I don't actually like either, but to each their own) languages so there are tons of sites to scrape for the info (might be a little harder since this is scripting within a specific program(s) (may have to mention that this is for the Adobe "runtime" and not necessarily for Node, Deno, Bun, SpiderMonkey or V8 etc (while there is a lot listed there, not much difference between them outside of who controls what))), that contributes to how "great" it is.
 

myront

Dammit, make it faster!!
Are you just selecting a text, outlining it and creating a bounding box .1" past to make weeding easier?

Is it adding additional vertical / horizontal lines based on a specific criteria?
Yes, this is to make weeding easier.
We have FineCut plugin but only on 1 pc and that's used by our print/plot tech. So instead of tying up his pc to do this task I decided to write my own that the designers can do from there own workstation. I have a l lot more set up that way too.
I made a macro to do this in CorelDRAW. It was super easy (see below). The script from above doesn't work so well in illustrator. The rectangle size doesn't end up up correctly in height.

1737748981301.png
 

Attachments

  • 1737748525717.png
    1737748525717.png
    26.3 KB · Views: 4
Top