BryanPagenkopf
Engaged
BryanPagenkopf
Engaged
Activity
‎Oct 21, 2024
01:11 PM
var userPath = $.getenv("USERPROFILE");
var cloudPath = decodeURI("/Layouts - Documents/");
var savePath = userPath + cloudPath;
// setup each possible location and it's save path
var locations = {
Sharepoint: savePath,
Local: "C:/Layout/",
};
// setup each possible product type and it's save path folder name
var products = {
Tool: "Tooled/",
Molten: "Molten/",
Buff: "Buff/",
HPPRINT: "Print/",
};
//****************************************************************************** */
function settingsWin(location, product) {
// settings window
var win = new Window("dialog");
win.text = "Production Art Save Options";
// create a radio button for each location
win.add("statictext", undefined, "Please Verify Your Location");
var gLocation = win.add("group");
var rb;
var locationRBs = [];
for (var k in locations) {
var rb = gLocation.add("radiobutton", undefined, k);
if (location == k) rb.value = true;
locationRBs.push(rb);
// Automatically select Sharepoint by default
if (k === "Sharepoint" || location == k) rb.value = true;
locationRBs.push(rb);
}
// create a radio button for each product
win.add("statictext", undefined, "Select Your Product Type");
var gProducts = win.add("group");
var rb;
var productRBs = [];
for (var k in products) {
var rb = gProducts.add("radiobutton", undefined, k);
if (product == k) rb.value = true;
productRBs.push(rb);
}
//--------------------------------------------------------------------------------------------------------
// pattern required panel
var gPatternRequired = win.add("group");
gPatternRequired.orientation = "column"; // set the orientation to column
gPatternRequired.alignChildren = ["center", "top"]; // center align the children vertically
var patternText = gPatternRequired.add(
"statictext",
undefined,
"Pattern Required?"
);
patternText.alignment = "center"; // center align the static text
var patternRBGroup = gPatternRequired.add("group");
patternRBGroup.alignment = "center"; // center align the radio button group
var patternYesRB = patternRBGroup.add("radiobutton", undefined, "Yes");
var patternNoRB = patternRBGroup.add("radiobutton", undefined, "No");
patternNoRB.value = true;
//---------------------------------------------------------------------------------------------------------
// group - window buttons
var gWindowButtons = win.add("group", undefined);
gWindowButtons.orientation = "row";
gWindowButtons.alignChildren = ["Leftwards", "center"];
gWindowButtons.alignment = ["center", "top"];
var btOK = gWindowButtons.add("button", undefined, "OK");
var btCancel = gWindowButtons.add("button", undefined, "Cancel");
var btDefaults = gWindowButtons.add("button", undefined, "Set Defaults");
// quote panel
var pInfo = win.add("panel", undefined);
var quote = "Every Choice You Make Has An End Result";
var author = "Zig Ziglar";
pInfo.add("statictext", undefined, quote);
pInfo.add("statictext", undefined, "- " + author);
// save defaults
var selectedProduct;
btDefaults.onClick = function () {
selectedProduct = captureRBSelection(productRBs);
if (selectedProduct) {
writeJSONData({ product: selectedProduct }, defaultProduct);
//alert("Default Product saved as " + selectedProduct + ".");
} else {
alert("Make sure to select both a Location and a Product first!");
}
};
function captureRBSelection(rbs) {
// check to see which product was selected
var selection = null;
for (var i = 0; i < rbs.length; i++) {
if (rbs[i].value) selection = rbs[i].text;
}
return selection;
}
// if "ok" button clicked then return inputs
if (win.show() == 1) {
var selectedLocation;
selectedLocation = captureRBSelection(locationRBs);
selectedProduct = captureRBSelection(productRBs);
// make sure both a location and a product was selected before continuing
if (selectedLocation && selectedProduct) {
return {
location: selectedLocation,
product: selectedProduct,
pattern: patternYesRB.value,
};
} else {
alert("Make sure to select both a Location and a Product first!");
return;
}
} else {
return;
}
}
... View more
‎Oct 21, 2024
12:17 PM
I have an array variable called "products". Each product has a radio button generated for it. Is there a way to have the script remember the radio button selection made the previous time the script was used? Thanks!
... View more
‎Apr 26, 2024
06:03 AM
1 Upvote
@jduncan I'll give that a shot thanks!
... View more
‎Apr 23, 2024
03:37 AM
The 2nd one on the right side should have more Raised square inches and for some reason does not, and I cannot figure out why.
... View more
‎Apr 22, 2024
09:34 AM
I have a script that calculates the area of production art Positive Space vs Negative Space. In my TestFile, the layout on the left works but the layout on the right does not. Can anyone assist me in adjusting the script so it works every time? function calculateRaisedArea() {
var decimalPlaces = 3;
var areaIn = 0;
var totalShapes = 0;
if (app.documents.length > 0) {
if (app.activeDocument.selection.length < 1) {
// alert('Select a path');
} else if (app.activeDocument.selection[0].area) {
// Individual Items
var objects = app.activeDocument.selection;
} else if (app.activeDocument.selection[0].pathItems) {
// Group/Compound Shape
var objects = app.activeDocument.selection[0].pathItems;
} else {
// alert('Please select a path or group.');
}
// Collect info
var totalArea = 0;
for (var i = 0; i < objects.length; i++) {
if (objects[i].area) {
totalArea += objects[i].area;
totalShapes++;
// Apply the graphic style to the current shape
var kerningOutline = app.activeDocument.graphicStyles.getByName("Kerning Outline");
kerningOutline.applyTo(objects[i]);
}
}
// Conversions
var ppi = 72;
areaIn = Math.abs(totalArea) / ppi / ppi;
}
return { area: areaIn, shapes: totalShapes };
}
function calculateTotalArea() {
var decimalPlaces = 3;
var largestArea = 0;
if (app.documents.length > 0) {
if (app.activeDocument.selection.length < 1) {
// alert('Select a path');
} else if (app.activeDocument.selection[0].area) {
// Individual Items
var objects = app.activeDocument.selection;
} else if (app.activeDocument.selection[0].pathItems) {
// Group/Compound Shape
var objects = app.activeDocument.selection[0].pathItems;
} else {
// alert('Please select a path or group.');
}
// Array to store paths and their areas
var pathsAndAreas = [];
// Calculate area for each path and store in array
for (var i = 0; i < objects.length; i++) {
if (objects[i].area) {
var ppi = 72;
var area = Math.abs(objects[i].area) / ppi / ppi;
pathsAndAreas.push(area);
}
}
// Find the largest area
for (var j = 0; j < pathsAndAreas.length; j++) {
if (pathsAndAreas[j] > largestArea) {
largestArea = pathsAndAreas[j];
}
}
}
return largestArea;
}
// Call the functions to execute the script
var raisedAreaObj = calculateRaisedArea();
var raisedArea = raisedAreaObj.area;
var totalShapes = raisedAreaObj.shapes;
var totalArea = calculateTotalArea();
var recessedArea = (totalArea - raisedArea).toFixed(3);
alert('Total Area: ' + totalArea.toFixed(3) + ' in\n' +
'Raised Area: ' + raisedArea.toFixed(3) + ' in\n' +
'Recessed Area: ' + recessedArea + ' in\n' +
'Number of Shapes: ' + totalShapes);
... View more
‎Apr 09, 2024
12:15 PM
1 Upvote
Recreate the action from the screenshot. This action should take care of what you need.
... View more
‎Sep 14, 2023
01:18 PM
2 Upvotes
@Rob.Wood I may be late to the game with your question but I think this script might accomplish what you are looking for. // Script to Delete Layers Containing Selected Objects
(function () {
// Check if there is an active document
if (app.documents.length > 0) {
// Get the active document
var doc = app.activeDocument;
// Get the selected objects
var selectedObjects = doc.selection;
// Check if there are selected objects
if (selectedObjects.length > 0) {
// Loop through all layers in reverse order
for (var i = doc.layers.length - 1; i >= 0; i--) {
var layer = doc.layers[i];
// Check if any selected object is on this layer
var deleteLayer = false;
for (var j = 0; j < selectedObjects.length; j++) {
if (selectedObjects[j].layer == layer) {
deleteLayer = true;
break;
}
}
// If the layer should be deleted, remove it
if (deleteLayer) {
layer.remove();
}
}
// Alert when the process is completed
alert("Selected objects' layers have been deleted.");
} else {
// No selected objects found
alert("No objects are currently selected.");
}
} else {
// No active document found
alert("No active document found.");
}
})();
Hope this Helps!
... View more
‎May 15, 2023
07:13 AM
I have a script that looks at the active selection. Always an outlined letter with dots inside. It then checks to see if there are two paths that are on the exact same Y axis. If it finds any paths it creates groups of two path items. I'm having two issues I could use help with. 1. I'm getting an error - Error 1302: No Such Element 2. I'd love to just select the whole layout and have it loop through each outlined character. The dots are always black, but to illustrate which dots would get grouped I colored them in the example file. Thank you! if (app.documents.length > 0) {
if (app.activeDocument.selection.length > 0) {
// group items by vertical separation (line)
var groups = groupObjectsByLine(app.activeDocument.selection);
if (groups) {
var paths;
// iterate over each group of objects
for (var i = 0; i < groups.length; i++) {
paths = [];
// capture all pageItems within the group
// so that a standard array can be passed to adjustOffset
for (var j = 0; j < groups[i].pageItems.length; j++) {
paths.push(groups[i].pageItems[j]);
}
// if a group has 2 items already, create a new group
if (groups[i].pageItems.length === 2) {
var matchingSize = groups[i].pageItems.every(function(p) {
return p.width === groups[i].pageItems[0].width && p.height === groups[i].pageItems[0].height;
});
if (matchingSize) {
var g = app.activeDocument.groupItems.add();
groups.push(g);
g.pageItems.add(paths[0]);
g.pageItems.add(paths[1]);
groups[i].remove();
i--;
}
}
}
}
}
}
/**
* Take an array of Adobe Illustrator pageItems and group them by vertical separation.
* @Param {Array} sel Adobe Illustrator pageItems
* @Returns {Array} Array of Adobe Illustrator groupItems
*/
function groupObjectsByLine(sel) {
var groups = [];
// sort the selected page items by their position (left to right, top to bottom)
sel.sort(function (a, b) {
if (a.top === b.top) {
return a.left - b.left;
} else {
return a.top - b.top;
}
});
// check if each page item shares bounds with others
var item, placed;
while (sel.length > 0) {
item = sel.pop();
placed = false;
for (var i = 0; i < groups.length; i++) {
var group = groups[i];
if (overlappingBounds(item, group)) {
item.move(group, ElementPlacement.PLACEATEND);
placed = true;
group.pageItems.add(item);
break;
}
}
// if an item didn't fit into any current groups make a new group
if (!placed) {
var g = app.activeDocument.groupItems.add();
groups.push(g);
item.move(g, ElementPlacement.PLACEATEND);
}
}
return groups;
}
/**
* Check if a pageItems bounds overlaps with a groupItem.
* @Param {pageItem} item Adobe Illustrator pageItem
* @Param {groupItem} group Adobe Illustrator groupItem
* @Returns {Boolean}
*/
function overlappingBounds(item, group) {
var top = item.geometricBounds[1];
var bottom = item.geometricBounds[3];
var gTop = group.geometricBounds[1];
var gBottom = group.geometricBounds[3];
if (gTop !== top) {
return false;
}
return true;
}
... View more
‎Apr 14, 2023
09:38 AM
Hello All, Is there a way Script wise that I can only duplicate the outermost path of a Compound Path? My first attempt was to duplicate the whole compound path which worked... if I selected the Script manually... and did not work when I used the Action Panel to call the Script. var objectHeight = selectedObject.height;
var objectWidth = selectedObject.width;
var duplicatedObject = selectedObject.duplicate();
duplicatedObject.left = selectedObject.left - (objectWidth * 2);
app.activeDocument.selection = null;
duplicatedObject.selected = true;
app.executeMenuCommand("noCompoundPath");
app.executeMenuCommand("ungroup");
... View more
‎Mar 08, 2023
07:01 AM
So I am getting some additional garbage in my text file. The date format changes to a numeric format and my dimension text example: (4"w x 6"h) come into the txt file as ("4""w x 6""h") Any Ideas on how I can fix that?
... View more
‎Mar 01, 2023
07:04 AM
Okay so here is what I did.... I wrote a macro within my Excel document to copy the selected cells and save them to a text file called "Spec.txt". Then write a script that would do a find and replace to fill in the needed data. Finally, the script clears the txt file so that there's no fear of importing the wrong data. // Get a reference to the currently active document
var doc = app.activeDocument;
var sel = doc.selection;
// Call the function to get the text string from a file and replace the contents of any text frames containing the word "ordnum"
getspecInformation();
// This function reads the contents of a file and returns them as a string
function getspecInformation() {
var specText = getTextString("C:/Users/Public/Spec.txt");
// If the file exists and is not empty
if (specText !== null && specText !== "") {
// Replace the contents of any text frames containing the word "ordnum" with the contents of the file
replaceText(specText);
}
}
// This function reads the contents of a file and returns them as a string
function getTextString(filePath) {
var textString;
var file = new File(filePath);
// If the file exists
if (file.exists) {
// Open the file in read mode
file.open("r"); // "r" stands for read
// Read the contents of the file into a string
textString = file.read();
// Close the file
file.close();
// Return the string containing the file contents
return textString;
} else {
// If the file does not exist, return null
return null;
}
}
// This function searches for the word "ordnum" in any text frames in the document and replaces it with the specified text
function replaceText(specText) {
// Create a regular expression to search for the word "ordnum" (with the "g" flag for a global search)
var searchString = /ordnum/g; // g for global search, remove i to make a case sensitive search
// Get a reference to all the text frames in the document
var textFrames = doc.textFrames;
// Declare some variables for use in the loop
var thisTF, newString;
// If there are any text frames in the document
if (textFrames.length > 0) {
// Loop through each text frame
for (var i = 0; i < textFrames.length; i++) {
thisTF = textFrames[i];
// If the contents of the text frame contain the word "ordnum"
if (thisTF.contents.indexOf("ordnum") !== -1) {
// Replace the word "ordnum" with the specified text
newString = thisTF.contents.replace(searchString, specText);
// Set the contents of the text frame to the new string
thisTF.contents = newString;
}
}
}
// Call the function to clear the contents of the file used for replacement
clearFileContents("C:/Users/Public/Spec.txt");
}
// This function clears the contents of the specified file
function clearFileContents(filePath) {
// Create a new file object using the specified file path
var file = new File(filePath);
// If the file exists
if (file.exists) {
var fileLength = file.length;
if (fileLength > 0) {
file.open("w"); // "w" stands for write
file.close();
}
}
}
... View more
‎Feb 28, 2023
11:55 AM
@Mylenium yeah I knew they didn't really communicate all that well unless the excel file was a simple XML, but wasn't sure if there was a way to "code around" the issue by way of some how some way creating a JSON file or the like. But I've been amazed at what scripts have been able to accomplish so I thought I would make the ask 🙂
... View more
‎Feb 28, 2023
06:10 AM
Currently, I have to copy data from an online PDF into an XSLM Exel file. Then using a Macro I am able to pull and organize the needed data into a column L15:L32 Last, back in my Illustrator file I have Tethered Text Boxes, the 1st one contains the text "xxxx", I select that and "CTRL+V" to paste in the needed data. Is it possible for a Script to grab the data from the active tab in Excel and do a Find and Replace if that script knows the name and location of the Excel file? C:\Users\Public\Spec Work.xlsm Any and all feedback welcome on this 🙂
... View more
‎Feb 15, 2023
11:25 AM
I ran this code and it fixed all of the characters except the "?" var doc = app.activeDocument;
var sel = doc.selection;
for (var i = 0; i < sel.length; i++) {
var item = sel[i];
if (item.typename === 'CompoundPathItem') {
var paths = item.pathItems;
var p = item.pathItems.length;
if (p == 3) {
// if count == 3, keep 2
item.pathItems[1].remove();
item.pathItems[0].remove();
}
else if (p == 6) {
// - if count == 6, keep 0, 5
item.pathItems[4].remove();
item.pathItems[3].remove();
item.pathItems[2].remove();
item.pathItems[1].remove();
}
else if (p == 9) {
// - if count == 9, keep 0, 3, 8
item.pathItems[7].remove();
item.pathItems[6].remove();
item.pathItems[5].remove();
item.pathItems[4].remove();
item.pathItems[2].remove();
item.pathItems[1].remove();
}
}
}
... View more
‎Feb 15, 2023
07:27 AM
1 Upvote
Thank you! I'll have to play around with "i" "j" ":" ";" characters var doc = app.activeDocument;
var sel = doc.selection;
for (var i = 0; i < sel.length; i++) {
var item = sel[i];
if (item.typename === 'CompoundPathItem') {
var paths = item.pathItems;
var p = item.pathItems.length;
if (p == 3) {
// if count == 3, keep 2
item.pathItems[1].remove();
item.pathItems[0].remove();
}
else if (p == 6) {
// - if count == 6, keep 0, 5
item.pathItems[4].remove();
item.pathItems[3].remove();
item.pathItems[2].remove();
item.pathItems[1].remove();
}
else if (p == 9) {
// - if count == 9, keep 0, 3, 8
item.pathItems[7].remove();
item.pathItems[6].remove();
item.pathItems[5].remove();
item.pathItems[4].remove();
item.pathItems[2].remove();
item.pathItems[1].remove();
}
}
}
... View more
‎Feb 14, 2023
12:22 PM
@femkeblanco I believe you are correct. Here is the PDF version
... View more
‎Feb 14, 2023
11:05 AM
I'm not sure why but I am getting mixed results with your script @femkeblanco The 2nd "A" turned out how it should 🙂
... View more
‎Feb 14, 2023
09:42 AM
Hey Everyone, I've been trying to write a script to remove the inside paths leaving the needed ones behind, but I can't get it quite right... // Get the active document and selection
var doc = app.activeDocument;
var sel = doc.selection;
// Loop through the selection
for (var i = 0; i < sel.length; i++) {
var item = sel[i];
// Check if the item is a compound path
if (item.typename === 'CompoundPathItem') {
// Get the paths in the compound path
var paths = item.pathItems;
// Check the number of paths in the compound path
if (paths.length > 2) {
// If there are more than 2 paths, delete all but the outside and inside most paths
var numPaths = paths.length;
var firstPath = paths[0];
var lastPath = paths[numPaths - 1];
var secondPath = paths[1];
var secondLastPath = paths[numPaths - 2];
if (numPaths === 3) {
// If there are only 3 paths, delete the middle path
secondPath.remove();
} else {
// If there are more than 3 paths, delete all but the outside and inside most paths
for (var j = numPaths - 2; j > 1; j--) {
secondPath.remove();
lastPath.remove();
}
}
}
}
}
... View more
‎Feb 10, 2023
09:20 AM
2 Upvotes
@Max Mugen Give this a Try: // Get the active document
var doc = app.activeDocument;
// Get an array of all existing layers
var allLayers = [];
for (var i = 0; i < doc.layers.length; i++) {
allLayers.push(doc.layers[i]);
}
// Get the active layer
var activeLayer = doc.activeLayer;
// Get the index of the active layer
var activeLayerIndex = -1;
for (var i = 0; i < allLayers.length; i++) {
if (allLayers[i] == activeLayer) {
activeLayerIndex = i;
break;
}
}
// Create a dialog window to ask the user to move the active layer up or down
var moveUpDownDialog = new Window("dialog", "Move Active Layer");
// Add a button group to the dialog window
var moveUpDownButtonGroup = moveUpDownDialog.add("group");
moveUpDownButtonGroup.orientation = "row";
// Add a "Move Up" button to the button group
var moveUpButton = moveUpDownButtonGroup.add("button", undefined, "Move Up");
moveUpButton.onClick = function() {
// Check if the active layer can be moved up
if (activeLayerIndex > 0) {
// Get the layer above the active layer
var layerAbove = allLayers[activeLayerIndex - 1];
// Move the active layer above the layer above it
activeLayer.move(layerAbove, ElementPlacement.PLACEBEFORE);
// Close the dialog window
moveUpDownDialog.close();
}
};
// Add a "Move Down" button to the button group
var moveDownButton = moveUpDownButtonGroup.add("button", undefined, "Move Down");
moveDownButton.onClick = function() {
// Check if the active layer can be moved down
if (activeLayerIndex < allLayers.length - 1) {
// Get the layer below the active layer
var layerBelow = allLayers[activeLayerIndex + 1];
// Move the active layer below the layer below it
activeLayer.move(layerBelow, ElementPlacement.PLACEAFTER);
// Close the dialog window
moveUpDownDialog.close();
}
};
// Show the dialog window
moveUpDownDialog.show();
... View more
‎Feb 02, 2023
10:40 AM
@Met1 I have not updated windows. I have uninstalled, reinstalled, applied all updates for Illustrator but no luck in fixing the issue 😞
... View more
‎Feb 02, 2023
10:39 AM
@Monika Gause I had thought of that too... but that wasn't the case. The scripts will give me the error then I hit the function key again and it works.
... View more
‎Feb 02, 2023
09:01 AM
@Met1I have them all saved here: C:\Program Files\Adobe\Adobe Illustrator 2023\Presets\en_US\Scripts So they should be because I can call them up manually by going to File - Scripts
... View more
‎Jan 23, 2023
07:20 AM
Is there a way to convert these 3 actions into a Script? I would choose which of the 3 to run based on a Radio Button Selection. (NA, 4 Corners, 2 Vertical, 2 Horizontal) NA button would do nothing 4 Corners Button - Select Direction Handles of top most path - Clear - Apply Graphic Style by Name (this would be part of a Dropdown menu selection) 2 Vertical Button - Select Direction Handles of top most path - Clear - Alignment - Horizontal Align Center - Apply Graphic Style by Name (this would be part of a Dropdown menu selection) - Expand Appearance - Pathfinder - Add 2 Horizontal Button - Select Direction Handles of top most path - Clear - Alignment - Vertical Align Center - Apply Graphic Style by Name (this would be part of a Dropdown menu selection) - Expand Appearance - Pathfinder - Add Here is the code as it exists today... Ugly but Functioning var doc = app.activeDocument;
var myLayer = doc.activeLayer;
// Create the window
var win = new Window("dialog", "Path Dimensions");
// Create a group to hold the width and height fields
var dimGroup = win.add("group");
// Add the width and height input fields
dimGroup.add("statictext", undefined, "Width (inches):");
var widthField = dimGroup.add("edittext", undefined, 8);
//widthField.text = 5;
widthField.preferredSize.width = 50;
dimGroup.add("statictext", undefined, "Height (inches):");
var heightField = dimGroup.add("edittext", undefined, 10);
//heightField.text = 5;
heightField.preferredSize.width = 50;
win.add("statictext", undefined, "Offset (inches):");
var offsetField = win.add("edittext", undefined, -0.125);
//offsetField.text = -0.125;
offsetField.preferredSize.width = 50;
win.add("statictext", undefined, "Offset (inches):");
var offsetField2 = win.add("edittext", undefined, 0);
//offsetField2.text = "";
offsetField2.preferredSize.width = 50;
win.add("statictext", undefined, "Offset (inches):");
var offsetField3 = win.add("edittext", undefined, 0);
//offsetField3.text = "";
offsetField3.preferredSize.width = 50;
win.add("statictext", undefined, "Offset (inches):");
var offsetField4 = win.add("edittext", undefined, 0);
//offsetField4.text = "";
offsetField4.preferredSize.width = 50;
win.add("statictext", undefined, "Offset For Stud Placement (inches):");
var offsetField5 = win.add("edittext", undefined, 0);
//offsetField5.text = "";
offsetField5.preferredSize.width = 50;
// Add the radio buttons
var radioGroup = win.add("group");
var rectButton = radioGroup.add("radiobutton", undefined, "Rectangle");
rectButton.value = true;
var ellipseButton = radioGroup.add("radiobutton", undefined, "Elliptical");
// Add the Stud radio buttons
var studGroup = win.add("group");
win.add("statictext", undefined, "Stud Placement");
var naButton = studGroup.add("radiobutton", undefined, "N/A");
naButton.value = true;
var fourstudButton = studGroup.add("radiobutton", undefined, "4 Studs");
var twohstudButton = studGroup.add("radiobutton", undefined, "2 Horizontal");
var twovstudButton = studGroup.add("radiobutton", undefined, "2 Vertical");
// Add the OK and cancel buttons
var btnGroup = win.add("group");
btnGroup.add ("statictext", undefined, "Select Stud Size");
var lines = btnGroup.add("dropdownlist",undefined,["#4", "#6", "#8", "#10", "#12", "#14", "1/4-20"]);
btnGroup.add("button", undefined, "OK", { name: "ok" });
btnGroup.add("button", undefined, "Cancel", { name: "cancel" });
// Check if the OK button was clicked
if (win.show() == 1) {
// Get the width, height, and offset values
var wdth = widthField.text * 72;
var hdth = heightField.text * 72;
var offset = offsetField.text * 72;
var offset2 = (parseFloat(offsetField2.text) + parseFloat(offsetField.text)) * 72;
var offset3 = (parseFloat(offsetField3.text) + parseFloat(offsetField2.text) + parseFloat(offsetField.text)) * 72;
var offset4 = (parseFloat(offsetField4.text) + parseFloat(offsetField3.text) + parseFloat(offsetField2.text) + parseFloat(offsetField.text)) * 72;
var offset5 = (parseFloat(offsetField5.text) + parseFloat(offsetField4.text) + parseFloat(offsetField3.text) + parseFloat(offsetField2.text) + parseFloat(offsetField.text)) * 72;
/*
alert(offsetField.text);
alert(offset);
alert(offsetField2.text);
alert(offset2);
alert(offsetField3.text);
alert(offset3);
alert(offsetField4.text);
alert(offset4);
alert(offsetField5.text);
alert(offset5);
*/
// Create the path
var pathTop = -1000;
var pathLeft = 1000;
var path = rectButton.value
? myLayer.pathItems.rectangle(pathTop, pathLeft, wdth, hdth)
: myLayer.pathItems.ellipse(pathTop, pathLeft, wdth, hdth);
// Set path colors
var pathColor = new CMYKColor();
pathColor.cyan = 100;
pathColor.magenta = 100;
pathColor.yellow = 100;
pathColor.black = 100;
path.stroked = false;
path.fillColor = pathColor;
// Create Offset Path
if (offset != 0) {
var offsetPath = rectButton.value
? myLayer.pathItems.rectangle(
pathTop + offset,
pathLeft - offset,
wdth + offset * 2,
hdth + offset * 2
)
: myLayer.pathItems.ellipse(
pathTop + offset,
pathLeft - offset,
wdth + offset * 2,
hdth + offset * 2
);
// Create Offset2 Path
if (offset2 < offset) {
var offsetPath2 = rectButton.value
? myLayer.pathItems.rectangle(
pathTop + offset2,
pathLeft - offset2,
wdth + offset2 * 2,
hdth + offset2 * 2
)
: myLayer.pathItems.ellipse(
pathTop + offset2,
pathLeft - offset2,
wdth + offset2 * 2,
hdth + offset2 * 2
);
// Create offset3 Path
if (offset3 < offset2) {
var offsetPath3 = rectButton.value
? myLayer.pathItems.rectangle(
pathTop + offset3,
pathLeft - offset3,
wdth + offset3 * 2,
hdth + offset3 * 2
)
: myLayer.pathItems.ellipse(
pathTop + offset3,
pathLeft - offset3,
wdth + offset3 * 2,
hdth + offset3 * 2
);
// Create offset4 Path
if (offset4 < offset3) {
var offsetPath4 = rectButton.value
? myLayer.pathItems.rectangle(
pathTop + offset4,
pathLeft - offset4,
wdth + offset4 * 2,
hdth + offset4 * 2
)
: myLayer.pathItems.ellipse(
pathTop + offset4,
pathLeft - offset4,
wdth + offset4 * 2,
hdth + offset4 * 2
);
// Create offset5 Path
if (offset5 != 0) {
var offsetPath5 = rectButton.value
? myLayer.pathItems.rectangle(
pathTop + offset5,
pathLeft - offset5,
wdth + offset5 * 2,
hdth + offset5 * 2
)
: myLayer.pathItems.ellipse(
pathTop + offset5,
pathLeft - offset5,
wdth + offset5 * 2,
hdth + offset5 * 2
);
// Enable the following line if you want the offset path below the path
// offsetPath.move(path, ElementPlacement.PLACEAFTER);
// Set offset path color
var offsetColor = new CMYKColor();
offsetColor.cyan = 0;
offsetColor.magenta = 0;
offsetColor.yellow = 0;
offsetColor.black = 100;
offsetPath.stroked = false;
offsetPath.fillcolor = offsetColor;
}
} else {
alert("No path created");
}
}
}
}
}
... View more
‎Jan 19, 2023
09:19 AM
@jduncan Thanks, the final piece to this script I need is to have the offset create an offset rectangle/ellipse path, if the value entered is not 0 (or Blank), centered with the parent shape. Basic Scripts I can read and tweak... these last several have been way out of my league...
... View more
‎Jan 19, 2023
09:08 AM
That allows the Rectangle to be created at 5 x 5 which I wanted as default values. Apparently, I have two other issues 😞 1. 5 x 5 must be hard-coded in because I just tried to do 10 x 5 and it still created a 5 x 5 rectangle. 2. I tried to do the ellipse and it crashes my illustrator.
... View more
‎Jan 19, 2023
08:07 AM
Hello, For the past several weeks I have randomly gotten an error that reads, "The object "[script name]" is not currently available." I am calling my scripts via a function key set up in my Actions Panel. It just randomly happens and with different scripts. Has anyone else had this issue or even better fixed this issue?
... View more
‎Jan 19, 2023
06:47 AM
Hello I have a script that doesn't seem to be passing the field values I enter to create either a new Rectangle or Elliptical shape within the active document and layer. Where did I go wrong? var doc = app.activeDocument
var myLayer = doc.activeLayer
// Create the window
var win = new Window("dialog", "Path Dimensions");
// Create a group to hold the width and height fields
var dimGroup = win.add("group");
// Add the width and height input fields
dimGroup.add("statictext", undefined, "Width (inches):");
var widthField = dimGroup.add("edittext", undefined, 5);
widthField.value = 5;
widthField.preferredSize.width = 50;
dimGroup.add("statictext", undefined, "Height (inches):");
var heightField = dimGroup.add("edittext", undefined, 5);
heightField.value = 5;
heightField.preferredSize.width = 50;
win.add("statictext", undefined, "Offset (inches):");
var offsetField = win.add("edittext", undefined, 0);
offsetField.value = 0;
offsetField.preferredSize.width = 50;
// Add the radio buttons
var radioGroup = win.add("group");
var rectButton = radioGroup.add("radiobutton", undefined, "Rectangle");
rectButton.value = true;
var ellipseButton = radioGroup.add("radiobutton", undefined, "Elliptical");
// Add the OK and cancel buttons
var btnGroup = win.add("group");
btnGroup.add("button", undefined, "OK", {name: "ok"});
btnGroup.add("button", undefined, "Cancel", {name: "cancel"});
// Show the window
win.show();
// Check if the OK button was clicked
if (win.ok) {
// Get the width, height, and offset values
var wdth = widthField.value*72;
var hdth = heightField.value*72;
var offset = offsetField.value*72;
alert("Width is set to" + wdth)
alert("Height is set to" + hdth)
alert("Offset is set to" + offset)
// Create the path
if (rectButton.value) {
var myRect = createRectangle(myLayer, 200, 200, wdth, hdth);
function createRectangle(layer, x, y ,h ,w){
return layer.pathItems.rectangle((x), (y), (wdth), (hdth))
}
} else {
var path = app.activeDocument.pathItems.ellipse(0, 0, wdth, hdth);
}
path.stroked = false;
path.fillColor = new CMYKColor();
path.fillColor.cyan = 100;
path.fillColor.magenta = 100;
path.fillColor.yellow = 100;
path.fillColor.black = 100;
if(offset != 0) {
path.createOutline(offset);
}
} else {
alert("No path created");
} Thank you for your advice!
... View more
‎Jan 18, 2023
09:12 AM
1 Upvote
@m1b and @jduncan This is Fantastic! Thank you so much!, This works so much better than the limited action I've been using!
... View more
‎Jan 17, 2023
01:42 PM
@m1b it would need to work with any font and cap height ranges between .23" to 3" as well. Which is why I was thinking about creating the array of areas and then identifying where the largest gap is VS having a hard-coded size.
... View more
‎Jan 17, 2023
11:57 AM
// Get the active document
var doc = app.activeDocument;
// Get the selected items
var selection = doc.selection;
// Create a new CompoundPath
var compoundPath = doc.compoundPathItems.add();
// Loop through the selected items
for (var i = 0; i < selection.length; i++) {
var item = selection[i];
// Move the selected item into the CompoundPath
item.moveToBeginning(compoundPath);
} So I have this base code that will create Compound Paths. Is there a way to 1. Calculate the areas of the Overlapping Vectors Only 2. Store those calculations in an array (in order of largest to smallest) 3. Identify which two numbers in the array have the largest gap 4. Then only have it only apply a CompoundPath to those areas that are Greater than the smaller of the two numbers identified in the array? My goal is to be able to CompoundPath the "Plugs" of the "R" and the "A" and not the overlapping serifs.
... View more