diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96a7c74..bbc14a3 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,13 @@
+## addSelectedGradientsToSwatch.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## alignInCenterOfSpace(Horizontal).js
### 1.1.0 (2024-06-01)
### Added
@@ -99,6 +106,20 @@
+## convertToGlobalColor.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
+## convertToSpotColor.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## copyLineDown.js
### 1.0.1 (2022-10-28)
### Bug Fixes
@@ -121,6 +142,9 @@
## createColorChart.js
+### 2.2.0 (2024-09-16)
+### Added
+- Added supported units.
### 2.1.0 (2023-07-23)
### Added
- Added the function to select how to increase or decrease color values. (Addition or Intensity)
@@ -185,22 +209,29 @@
+## deleteAllSwatches.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## deleteHiddenLayers.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
## deleteLockedLayers.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
## deleteUnusedLayers.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
@@ -214,7 +245,7 @@
## disjoinPath.js
-### 1.1.0 (2024-08-04)
+### 1.1.0 (2024-08-10)
### Added
- Added the function to check the illustrator version.
### Bug Fixes
@@ -246,7 +277,7 @@
## drawNormalLine.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Bug Fixes
- Fixed a bug in the return value of the isFlat() function.
@@ -273,6 +304,13 @@
+## exportColorValuesToCSV.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## extendHandle.js
### 1.2.0 (2024-06-01)
### Added
@@ -297,7 +335,17 @@
+## extractColorsFromGradient.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## generateGradientColor.js
+### 1.0.2 (2024-09-16)
+### Changes
+- Refactoring.
### 1.0.1 (2023-09-18)
### Changes
- Changed localization method.
@@ -314,6 +362,9 @@
## highlightWord.js
+### 1.2.0 (2024-09-16)
+### Added
+- Added the functions to apply swatches, character and paragraph styles.
### 1.1.0 (2023-09-18)
### Features
- Regular expressions are now supported.
@@ -323,6 +374,9 @@
## importCSVtoSwatch.js
+### 1.2.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
### 1.2.0 (2023-04-08)
### Features
- Added support for 3-digit Hex color.
@@ -347,14 +401,14 @@
## invertLockedLayer.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
## invertVisibleLayer.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
@@ -422,13 +476,16 @@
## moveSublayerToMainLayer.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
## randomTextColor.js
+### 1.3.0 (2024-09-16)
+### Changes
+- Updated the UI.
### 1.2.1 (2023-09-18)
### Changes
- Changed localization method.
@@ -452,7 +509,7 @@
## relinkFileExtension.js
-### 1.1.1 (2024-08-04)
+### 1.1.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
### 1.1.0 (2023-01-15)
@@ -467,7 +524,13 @@
## relinkFileExtensionExtra.js
-### 1.3.0 (2024-08-04)
+### 1.3.1 (2024-09-16)
+### Changes
+- For CS6, CC and CC2014, changed to use the action to relink.
+- Changed requirements to CS6 or higher.
+### Bug Fixes
+- Fixed a bug that prevented rotation when PDF files were relinked.
+### 1.3.0 (2024-08-10)
### Added
- PDF is now supported.
- Unicode combining character sequence is now supported.
@@ -483,7 +546,7 @@
## relinkToFolder.js
-### 1.1.1 (2024-08-04)
+### 1.1.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
### 1.1.0 (2023-01-15)
@@ -501,15 +564,22 @@
+## removeDeletedGlobalColor.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## renameLinkedFile.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Unicode combining character sequence is now supported.
## resetToFullScale.js
-### 1.0.2 (2024-08-04)
+### 1.0.2 (2024-08-10)
### Added
- Added the function to check the illustrator version.
### 1.0.1 (2023-03-26)
@@ -518,8 +588,22 @@
+## roundColorValue.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
+## roundLocationOfGradientStop.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## selectEmbeddedLink.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
@@ -533,7 +617,7 @@
## selectLink.js
-### 1.2.0 (2024-08-04)
+### 1.2.0 (2024-08-10)
### Added
- Unicode combining character sequence is now supported.
### Changes
@@ -548,7 +632,7 @@
## showArtboardName.js
-### 1.3.0 (2024-08-04)
+### 1.3.0 (2024-08-10)
### Added
- Added supported units.
### Changes
@@ -563,6 +647,9 @@
## showColorValues.js
+### 1.1.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
### 1.1.0 (2023-04-08)
### Features
- Added support for Hex color.
@@ -587,8 +674,15 @@
+## shuffleGradientColor.js
+### 1.0.1 (2024-09-16)
+### Added
+- Added the function to check the illustrator version.
+
+
+
## sortArtboards.js
-### 1.0.1 (2024-08-04)
+### 1.0.1 (2024-08-10)
### Added
- Added the function to check the illustrator version.
@@ -627,6 +721,7 @@
### 2.0.0 (2024-06-30)
### Changes
- Changed the UI to allow editing of numeric values in text fields.
+
## syncView.js
@@ -661,7 +756,7 @@
## unifyLayerColors.js
-### 1.1.0 (2024-08-04)
+### 1.1.0 (2024-08-10)
### Added
- Added specification that locked layers do not change color.
- Added the function to check the illustrator version.
diff --git a/README.md b/README.md
index c6d7781..5f83317 100755
--- a/README.md
+++ b/README.md
@@ -10,8 +10,8 @@ If you find a script that interests you, please download it from [![Download](ht
### Artboard
[![Download Artboard.zip](https://img.shields.io/badge/Download-Artboard.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Artboard.zip)
-- [Rename Artboard](#renameArtboardjs) `New`
-- [Show Artboard Name](#showArtboardNamejs) `Update`
+- [Rename Artboard](#renameArtboardjs)
+- [Show Artboard Name](#showArtboardNamejs)
- [Sort Artboards](#sortArtboardsjs)
### Color
@@ -19,15 +19,15 @@ If you find a script that interests you, please download it from [![Download](ht
- [Add Selected Gradients to Swatch](#addSelectedGradientsToSwatchjs)
- [Convert to Global Color](#convertToGlobalColorjsconvertToSpotColorjs)
- [Convert to Spot Color](#convertToGlobalColorjsconvertToSpotColorjs)
-- [Create Color Chart](#createColorChartjs)
+- [Create Color Chart](#createColorChartjs) `Update`
- [Delete All Swatches](#deleteAllSwatchesjs)
- [Export Color Values to CSV](#exportColorValuesToCSVjs)
- [Extract Colors from Gradient](#extractColorsFromGradientjs)
- [Generate Gradient Color](#generateGradientColorjs)
-- [Highlight Word](#highlightWordjs)
+- [Highlight Word](#highlightWordjs) `Update`
- [Import CSV to Swatch](#importCSVtoSwatchjs)
- [Match Location of Gradient Stop](#matchLocationOfGradientStopjs)
-- [Random Text Color](#randomTextColorjs)
+- [Random Text Color](#randomTextColorjs) `Update`
- [Remove Deleted Global Color](#removeDeletedGlobalColorjs)
- [Round Color Value](#roundColorValuejs)
- [Round Location of Gradient Stop](#roundLocationOfGradientStopjs)
@@ -42,18 +42,19 @@ If you find a script that interests you, please download it from [![Download](ht
- [Invert Locked Layer](#invertLockedLayerjs)
- [Invert Visible Layer](#invertVisibleLayerjs)
- [Move Sublayer to Main Layer](#moveSublayerToMainLayerjs)
-- [Rename Layer](#renameLayerjs) `New`
-- [Unify Layer Colors](#unifyLayerColorsjs) `Update`
+- [Rename Layer](#renameLayerjs)
+- [Unify Layer Colors](#unifyLayerColorsjs)
### Link
[![Download Link.zip](https://img.shields.io/badge/Download-Link.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Link.zip)
+- [Bulk Relink](#bulkRelinkjs) `New`
- [Relink File Extension](#relinkFileExtensionjs)
-- [Relink File Extension Extra](#relinkFileExtensionExtrajs) `Update`
+- [Relink File Extension Extra](#relinkFileExtensionExtrajs) `Bug Fix`
- [Relink to Folder](#relinkToFolderjs)
-- [Rename Linked File](#renameLinkedFilejs) `Update`
+- [Rename Linked File](#renameLinkedFilejs)
- [Reset to Full Scale](#resetToFullScalejs)
- [Select Embedded Link](#selectEmbeddedLinkjs)
-- [Select Link](#selectLinkjs) `Update`
+- [Select Link](#selectLinkjs)
### Path
[![Download Path.zip](https://img.shields.io/badge/Download-Path.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Path.zip)
@@ -66,11 +67,11 @@ If you find a script that interests you, please download it from [![Download](ht
- [Create Grid Lines](#createGridLinesjs)
- [Decrease Selected Anchor Points Clockwise](#decreaseSelectedAnchorPointsCWjsdecreaseSelectedAnchorPointsCCWjs)
- [Decrease Selected Anchor Points Counterclockwise](#decreaseSelectedAnchorPointsCWjsdecreaseSelectedAnchorPointsCCWjs)
-- [Disjoin Path](#disjoinPathjs) `Bug Fix`
+- [Disjoin Path](#disjoinPathjs)
- [Distribute in Space (Horizontal)](#distributeInSpaceHorizontaljsdistributeInSpaceVerticaljs)
- [Distribute in Space (Vertical)](#distributeInSpaceHorizontaljsdistributeInSpaceVerticaljs)
- [Draw Circumscribed Circle](#drawCircumscribedCirclejs)
-- [Draw Normal Line](#drawNormalLinejs) `Bug Fix`
+- [Draw Normal Line](#drawNormalLinejs)
- [Draw Rectangle](#drawRectanglejs)
- [Draw Shape on Anchor Point](#drawShapeOnAnchorPointjs)
- [Draw Shape Parallel to Path Segment](#drawShapeParallelToPathSegmentjs)
@@ -159,6 +160,7 @@ To run the scripts, from File > Scripts > Other Script( ⌘ / Ct
## Extensions, software
The following extensions or software make it easy to run scripts.
+- [SPAi](https://tama-san.com/spai/) (Mac / free software)
- [Scripshon Trees](https://exchange.adobe.com/apps/cc/15873/scripshon-trees) (free extension)
- [LAScripts](https://exchange.adobe.com/apps/cc/19405/lascripts) (free extension)
- [Keyboard Maestro](https://www.keyboardmaestro.com) (Mac / paid software)
@@ -234,7 +236,7 @@ This script adds selected gradients to Swatches.
![Add Selected Gradients To Swatch](images/addSelectedGradientsToSwatch.png)
### Usage
-Select the path objects, and run this script.
+Select path objects, and run this script.
> [!NOTE]
> Text object and stroke color are not supported.
@@ -332,6 +334,33 @@ Illustrator CS6 or higher
+# bulkRelink.js
+[![Download Link.zip](https://img.shields.io/badge/Download-Link.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Link.zip)
+This script replaces missing links, linked and embedded files in bulk.
+
+> [!IMPORTANT]
+> Since version 2024, the Apply to All checkbox has been removed from the dialog that appears when there are missing link files. As a result, it is no longer possible to replace files in bulk using this dialog.
+
+![Bulk Relink](images/bulkRelink.png)
+
+### Usage
+1. Select any missing link, linked or embedded files, and run this script.
+2. Select a new file.
+3. For PDF, select a crop to option and enter a page number from the import options.
+
+> [!NOTE]
+> When selecting linked files, select them in the document rather than the Links panel.
+
+### Requirements
+Illustrator CS6 or higher
+
+
+
+
+
+
+
+
# checkDayOfWeek.js
[![Download Utility.zip](https://img.shields.io/badge/Download-Utility.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Utility.zip)
This script checks the day of the week.
@@ -464,7 +493,7 @@ convertToSpotColor.js:
### Usage
Select colors in the Swatches panel, and run this script.
-If you don't select them, all colors will target.
+If not selected, all swatches are converted.
> [!NOTE]
> If there is a swatch with the same name, it will not convert.
@@ -592,7 +621,7 @@ This script creates a color chart. Both CMYK and RGB colors are supported.
- `Addition` The value of the steps is added as is.
- `Intensity` The percentage of the target color is added. It is equivalent to Edit > Edit Colors > Saturate.
-7. Set the artboard size, color chip size, and units according to your preference.
+7. Set the units, artboard size, and color chip size according to your preference.
> [!NOTE]
> Spot color, gradient, and pattern are not supported.
@@ -1233,7 +1262,7 @@ This script extracts colors as swatches from the gradient stops.
![Extract Colors From Gradient](images/extractColorsFromGradient.png)
### Usage
-Select the path objects or swatches, and run this script.
+Select any path objects or swatches, and run this script.
> [!NOTE]
> Prioritize the path object over swatches.
@@ -1296,12 +1325,12 @@ Illustrator CS or higher
# generateGradientColor.js
[![Download Color.zip](https://img.shields.io/badge/Download-Color.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Color.zip)
-This script generates the gradient color from fill colors or swatches.
+This script generates a gradient color from fill colors or swatches.
![Generate Gradient Color](images/generateGradientColor.png)
### Usage
-Select the path objects or swatches, and run this script.
+Select two or more path objects or swatches, and run this script.
> [!NOTE]
> Prioritize the path object over swatches.
@@ -1384,18 +1413,27 @@ Illustrator CC 2018 or higher
# highlightWord.js
[![Download Color.zip](https://img.shields.io/badge/Download-Color.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Color.zip)
-This script highlights the searched words with the fill color.
+This script highlights the searched string by fill color, swatch or character style.
Both CMYK and RGB colors are supported.
![Highlight Word](images/highlightWord.png)
### Usage
-1. Select any text objects, and run this script.
-2. Enter a word. Regular expressions are supported.
-3. Use the slider to specify the color if necessary.
+1. Select any text objects, and run this script.
+ If no texts are selected, it highlights all texts in the document.
+2. Enter a string. Regular expressions are supported.
+3. To specify a color, enter the color values or use the sliders
+4. To specify a swatch, select a swatch name from the list on the Swatches tab and check the Ignore Color Settings checkbox.
+5. To specify a character style, select a style name from the list on the Character Styles tab.
+6. To specify a paragraph style, select a style name from the list on the Paragraph Styles tab.
+
+If you wish to color the character and paragraph styles, uncheck the Ignore Color Settings checkbox.
+
+> [!NOTE]
+> Color and swatch cannot be applied at the same time.
### Requirements
-Illustrator CS4 or higher
+Illustrator CS6 or higher
@@ -1742,9 +1780,9 @@ Both CMYK and RGB colors are supported.
![Random Text Color](images/randomTextColor.png)
### Usage
-1. Select the text objects, and run this script.
-2. Assign the threshold value with the slider.
-3. Click the Random button to assign a color according to the threshold value.
+1. Select any text objects, and run this script.
+2. Enter the color values or use the sliders to set the threshold.
+3. Click the Random button to change the color according to the threshold value.
> [!NOTE]
> If there are many characters, the conversion will take time.
@@ -1803,7 +1841,7 @@ For more advanced settings, use [relinkFileExtensionExtra.js](#relinkFileExtensi
![Relink File Extension](images/relinkFileExtension.png)
### Usage
-1. Select any linked files, and run this script. If no file is selected, it replaces all files in the document.
+1. Select any linked files, and run this script. If no files are selected, it replaces all files in the document.
2. Enter an extension.
> [!WARNING]
@@ -1830,13 +1868,13 @@ This script is an enhanced version of [relinkFileExtension.js](#relinkFileExtens
![Relink File Extension Extra](images/relinkFileExtensionExtra.png)
### Usage
-1. Select any linked files, and run this script. If no file is selected, it replaces all files in the document.
+1. Select any linked files, and run this script. If no files are selected, it replaces all files in the document.
2. Select either file renaming method.
- `Replace` Enter the current file name in the Find field and a new file name in the Replace field.
It can also be part of the file name. Regular expressions are supported in the Find field.
- `Add` Enter a string to be added to the prefix, suffix, or both of the original file names.
3. Enter an extension. If the file extension is the same, enter nothing.
-4. If you specify PDF as the extension, enter the page number and select the Crop to option.
+4. If you specify PDF as the extension, select the Crop to option and enter the page number.
**See also:** [Import Adobe PDF files](https://helpx.adobe.com/illustrator/using/importing-pdf-files.html)
5. To change the folder for the linked file, select a new folder.
If the folder is the same as the original file, select nothing.
@@ -1849,7 +1887,7 @@ This script is an enhanced version of [relinkFileExtension.js](#relinkFileExtens
> When selecting linked files, select them in the document rather than the Links panel.
### Requirements
-Illustrator CS4 or higher
+Illustrator CS6 or higher
@@ -1864,7 +1902,7 @@ This script replaces linked files with a file of the same name in the selected f
### Usage
1. Select any linked files, and run this script.
- If no file is selected, it replaces all files in the document.
+ If no files are selected, it replaces all files in the document.
2. Select a folder from the dialog that appears.
> [!WARNING]
@@ -1907,7 +1945,7 @@ Illustrator CS6 or higher
# removeDeletedGlobalColor.js
[![Download Color.zip](https://img.shields.io/badge/Download-Color.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Color.zip)
-This script deletes the Deleted Global Color displayed in the Separations Preview panel.
+This script deletes the Deleted Global Colors displayed in the Separations Preview panel.
![Remove Deleted Global Color](images/removeDeletedGlobalColor.png)
@@ -2065,7 +2103,7 @@ This script rounds color values. Both fill and stroke colors are supported.
![Round Color Value](images/roundColorValue.png)
### Usage
-Select the objects, and run this script.
+Select any objects, and run this script.
### Requirements
Illustrator CS or higher
@@ -2085,7 +2123,7 @@ Both fill and stroke colors are supported.
![Round Location Of Gradient Stops](images/roundLocationOfGradientStops.png)
### Usage
-Select the objects, and run this script.
+Select any objects, and run this script.
### Requirements
Illustrator CS or higher
@@ -2212,7 +2250,7 @@ This script shows color values. Both fill and stroke colors are supported.
![Show Color Values](images/showColorValues.png)
### Usage
-Select path objects, and run this script.
+Select any path objects, and run this script.
> [!NOTE]
> CMYK, RGB, HEX, grayscale, spot color, and pattern are supported.
@@ -2267,7 +2305,7 @@ This script shuffles the gradient color.
![Shuffle Gradient Color](images/shuffleGradientColor.png)
### Usage
-Select the path objects, and run this script.
+Select any path objects, and run this script.
> [!NOTE]
> Only a fill color. A stroke color is not supported.
diff --git a/README_ja.md b/README_ja.md
index a0191cb..1d632f3 100755
--- a/README_ja.md
+++ b/README_ja.md
@@ -8,8 +8,8 @@ Adobe Illustratorのスクリプト集です。
### アートボード
[![Download Artboard.zip](https://img.shields.io/badge/Download-Artboard.zip-e60012?style=for-the-badge)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Artboard.zip)
-- [**アートボードの名前とサイズを表示**](#アートボードの名前とサイズを表示) showArtboardName.js `Update`
-- [**アートボードの名前を変更**](#アートボードの名前を変更) renameArtboard.js `New`
+- [**アートボードの名前とサイズを表示**](#アートボードの名前とサイズを表示) showArtboardName.js
+- [**アートボードの名前を変更**](#アートボードの名前を変更) renameArtboard.js
- [**アートボードの並べ替え**](#アートボードの並べ替え) sortArtboards.js
### カラー
@@ -19,7 +19,7 @@ Adobe Illustratorのスクリプト集です。
- [**カラー数値をCSVファイルに保存**](#カラー数値をCSVファイルに保存) exportColorValuesToCSV.js
- [**カラー数値を四捨五入**](#カラー数値を四捨五入) roundColorValue.js
- [**カラー数値を表示**](#カラー数値を表示) showColorValues.js
-- [**カラーチャートを作成**](#カラーチャートを作成) createColorChart.js
+- [**カラーチャートを作成**](#カラーチャートを作成) createColorChart.js `Update`
- [**グラデーションのカラー分岐点から色を取り出す**](#グラデーションのカラー分岐点から色を取り出す) extractColorsFromGradient.js
- [**グラデーションのカラー分岐・中間点の位置を同期**](#グラデーションのカラー分岐中間点の位置を同期) matchLocationOfGradientStop.js
- [**グラデーションのカラー分岐・中間点の数値を四捨五入**](#グラデーションのカラー分岐中間点の数値を四捨五入) roundLocationOfGradientStop.js
@@ -28,8 +28,8 @@ Adobe Illustratorのスクリプト集です。
- [**グラデーションを生成**](#グラデーションを生成) generateGradientColor.js
- [**グローバルカラーに変換**](#グローバルカラーに変換特色に変換) convertToGlobalColor.js
- [**すべてのスウォッチを削除**](#すべてのスウォッチを削除) deleteAllSwatches.js
-- [**単語の塗り色を変更**](#単語の塗り色を変更) highlightWord.js
-- [**テキストの塗り色をランダムに変更**](#テキストの塗り色をランダムに変更) randomTextColor.js
+- [**テキストの色を変更**](#テキストの色を変更) highlightWord.js `Update`
+- [**テキストの色をランダムに変更**](#テキストの色をランダムに変更) randomTextColor.js `Update`
- [**特色に変換**](#グローバルカラーに変換特色に変換) convertToSpotColor.js
### レイヤー
@@ -38,8 +38,8 @@ Adobe Illustratorのスクリプト集です。
- [**非表示レイヤーを削除**](#非表示レイヤーを削除) deleteHiddenLayers.js
- [**表示状態を反転**](#表示状態を反転) invertVisibleLayer.js
- [**未使用レイヤーを削除**](#未使用レイヤーを削除) deleteUnusedLayers.js
-- [**レイヤーカラーを統合**](#レイヤーカラーを統合) unifyLayerColors.js `Update`
-- [**レイヤー名の変更**](#レイヤー名の変更) renameLayer.js `New`
+- [**レイヤーカラーを統合**](#レイヤーカラーを統合) unifyLayerColors.js
+- [**レイヤー名の変更**](#レイヤー名の変更) renameLayer.js
- [**ロック状態のレイヤーを削除**](#ロック状態のレイヤーを削除) deleteLockedLayers.js
- [**ロック状態を反転**](#ロック状態を反転) invertLockedLayer.js
@@ -47,11 +47,12 @@ Adobe Illustratorのスクリプト集です。
[![Download Link.zip](https://img.shields.io/badge/Download-Link.zip-e60012?style=for-the-badge)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Link.zip)
- [**埋め込み画像を選択**](#埋め込み画像を選択) selectEmbeddedLink.js
- [**ファイル拡張子にリンクを再設定**](#ファイル拡張子にリンクを再設定) relinkFileExtension.js
-- [**ファイル拡張子にリンクを再設定(機能拡張版)**](#ファイル拡張子にリンクを再設定機能拡張版) relinkFileExtensionExtra.js `Update`
+- [**ファイル拡張子にリンクを再設定(機能拡張版)**](#ファイル拡張子にリンクを再設定機能拡張版) relinkFileExtensionExtra.js `Bug Fix`
- [**フォルダに再リンク**](#フォルダに再リンク) relinkToFolder.js
-- [**リンク画像の名前を変更**](#リンク画像の名前を変更) renameLinkedFile.js `Update`
+- [**まとめてリンクを再設定**](#まとめてリンクを再設定) bulkRelink.js `New`
+- [**リンク画像の名前を変更**](#リンク画像の名前を変更) renameLinkedFile.js
- [**リンク画像を原寸サイズに戻す**](#リンク画像を原寸サイズに戻す) resetToFullScale.js
-- [**リンク画像を選択**](#リンク画像を選択) selectLink.js `Update`
+- [**リンク画像を選択**](#リンク画像を選択) selectLink.js
### パス
[![Download Path.zip](https://img.shields.io/badge/Download-Path.zip-e60012?style=for-the-badge)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Path.zip)
@@ -80,8 +81,8 @@ Adobe Illustratorのスクリプト集です。
- [**パスの寸法を表示**](#パスの寸法を表示) showDimensions.js
- [**パスを伸縮**](#パスを伸縮) extendLine.js
- [**パスを閉じる**](#パスを閉じる) closePath.js
-- [**パスを分解**](#パスを分解) disjoinPath.js `Bug Fix`
-- [**法線を描く**](#法線を描く) drawNormalLine.js `Bug Fix`
+- [**パスを分解**](#パスを分解) disjoinPath.js
+- [**法線を描く**](#法線を描く) drawNormalLine.js
- [**余白の垂直方向中央に整列**](#余白の垂直方向中央に整列余白の水平方向中央に整列) alignInCenterOfSpace(Vertical).js
- [**余白の水平方向中央に整列**](#余白の垂直方向中央に整列余白の水平方向中央に整列) alignInCenterOfSpace(Horizontal).js
- [**余白の垂直方向に分布**](#余白の垂直方向に分布余白の水平方向に分布) distributeInSpace(Vertical).js
@@ -354,6 +355,34 @@ Illustrator CS6以降
+## まとめてリンクを再設定
+[![Download Link.zip](https://img.shields.io/badge/Download-Link.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Link.zip)
+### bulkRelink.js
+リンク切れ画像、リンク画像、または埋め込み画像を一括で再設定します。
+
+> [!IMPORTANT]
+> バージョン2024以降、リンク切れ画像がある場合に表示するアラートから「すべてに適用」チェックボックスが削除されました。そのため、リンク画像を一括で置換することができなくなりました。
+
+![Bulk Relink](images/bulkRelink.png)
+
+#### 使用方法
+1. 再設定したいリンク切れ画像、リンク画像、または埋め込み画像を選択しスクリプトを実行します。
+2. 新しいリンク画像を選択します。
+3. PDFの場合、読み込みオプションからトリミングとページを選択します。
+
+> [!NOTE]
+> 画像を選択する場合は、リンクパネルではなくドキュメント内の画像を選択してください。
+
+#### 動作条件
+Illustrator CS6以降
+
+
+
+
+
+
+
+
## 日付と曜日の確認
[![Download Utility.zip](https://img.shields.io/badge/Download-Utility.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Utility.zip)
### checkDayOfWeek.js
@@ -635,7 +664,7 @@ Illustrator CC 2018以降
- `加算` 増減値をそのまま加算します。
- `濃度` 対象の色に対する割合を加算します。「編集 > カラーを編集 > 彩度調整」に相当します。
-7. アートボードサイズ、カラーチップサイズ、単位を設定します。
+7. 単位、アートボードサイズ、カラーチップサイズを設定します。
> [!NOTE]
> 特色、グラデーション、パターンには対応していません。
@@ -1480,22 +1509,31 @@ Illustrator CC 2018以降
-## 単語の塗り色を変更
+## テキストの色を変更
[![Download Color.zip](https://img.shields.io/badge/Download-Color.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Color.zip)
### highlightWord.js
-指定した単語の塗り色を変更します。CMYK、RGB のどちらにも対応しています。
+指定したテキストの塗り色を変更します。CMYK、RGB のどちらにも対応しています。
![Highlight Word](images/highlightWord.png)
> [!NOTE]
> Illustrator日本語版を使用している場合は、UIは日本語で表示します。
#### 使用方法
-1. テキストオブジェクトを選択してスクリプトを実行します。
-2. 単語を入力します。正規表現に対応しています。
-3. 必要に応じて色を設定します。
+1. テキストオブジェクトを選択してスクリプトを実行します。
+ なにも選択しない場合は、ドキュメント内のすべてのテキストが対象になります。
+2. 検索文字列にテキストを入力します。正規表現に対応しています。
+3. 色を指定するには、色の値を入力するか、スライダーを使用します。
+4. スウォッチを指定するには、スウォッチタブのリストからスウォッチ名を選択し、[カラー設定を無視]にチェックを付けます。
+5. 文字スタイルを指定するには、文字スタイルタブのリストからスタイル名を選択します。
+6. 段落スタイルを指定するには、段落スタイルタブのリストからスタイル名を選択します。
+
+文字、または段落スタイルに色を付けたい場合は、[カラー設定を無視]のチェックを外します。
+
+> [!NOTE]
+> カラーとスウォッチを同時に適用できません。
#### 動作条件
-Illustrator CS4以降
+Illustrator CS6以降
@@ -1857,10 +1895,10 @@ Illustrator CS4以降
-## テキストの塗り色をランダムに変更
+## テキストの色をランダムに変更
[![Download Color.zip](https://img.shields.io/badge/Download-Color.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Color.zip)
### randomTextColor.js
-単語または、1文字、1文ごとにランダムに色を適用します。CMYK、RGB のどちらにも対応しています。
+単語、1文字、または1文ごとにランダムに色を適用します。CMYK、RGB のどちらにも対応しています。
![Random Text Color](images/randomTextColor.png)
> [!NOTE]
@@ -1868,8 +1906,8 @@ Illustrator CS4以降
#### 使用方法
1. テキストオブジェクトを選択してスクリプトを実行します。
-2. スライダーで各色のしきい値を指定します。
-3. ランダムボタンをクリックすると、しきい値に応じた色が割り当てられます。
+2. 色の値を入力するか、スライダーを使用してしきい値を設定します。
+3. ランダムボタンをクリックすると、しきい値に応じた色を割り当てます。
> [!NOTE]
> 文字数が多いと変換に時間がかかります。
@@ -1985,7 +2023,7 @@ Illustrator CS4以降
> リンク画像を選択する場合は、リンクパネルではなくドキュメント内のリンク画像を選択してください。
#### 動作条件
-Illustrator CS4以降
+Illustrator CS6以降
diff --git a/images/addSelectedGradientsToSwatch.png b/images/addSelectedGradientsToSwatch.png
index 8d0aad1..c6d76ff 100644
Binary files a/images/addSelectedGradientsToSwatch.png and b/images/addSelectedGradientsToSwatch.png differ
diff --git a/images/bulkRelink.png b/images/bulkRelink.png
new file mode 100644
index 0000000..aa69284
Binary files /dev/null and b/images/bulkRelink.png differ
diff --git a/images/convertToGlobalColor.png b/images/convertToGlobalColor.png
index 206d8a2..d98e942 100644
Binary files a/images/convertToGlobalColor.png and b/images/convertToGlobalColor.png differ
diff --git a/images/convertToSpotColor.png b/images/convertToSpotColor.png
index 2cc7e57..0f5a19b 100644
Binary files a/images/convertToSpotColor.png and b/images/convertToSpotColor.png differ
diff --git a/images/createColorChart.png b/images/createColorChart.png
index 392d2ae..0bc9503 100644
Binary files a/images/createColorChart.png and b/images/createColorChart.png differ
diff --git a/images/deleteAllSwatches.png b/images/deleteAllSwatches.png
index 9ecf19a..6218d09 100644
Binary files a/images/deleteAllSwatches.png and b/images/deleteAllSwatches.png differ
diff --git a/images/exportColorValuesToCSV.png b/images/exportColorValuesToCSV.png
index f939f0d..3bf0695 100644
Binary files a/images/exportColorValuesToCSV.png and b/images/exportColorValuesToCSV.png differ
diff --git a/images/extractColorsFromGradient.png b/images/extractColorsFromGradient.png
index ac7af0a..8ac2307 100644
Binary files a/images/extractColorsFromGradient.png and b/images/extractColorsFromGradient.png differ
diff --git a/images/generateGradientColor.png b/images/generateGradientColor.png
index ac42168..93bba6c 100644
Binary files a/images/generateGradientColor.png and b/images/generateGradientColor.png differ
diff --git a/images/highlightWord.png b/images/highlightWord.png
index 8e50c94..c0c6446 100644
Binary files a/images/highlightWord.png and b/images/highlightWord.png differ
diff --git a/images/importCSVtoSwatch.png b/images/importCSVtoSwatch.png
index 9a84026..80e64a2 100644
Binary files a/images/importCSVtoSwatch.png and b/images/importCSVtoSwatch.png differ
diff --git a/images/matchLocationOfGradientStop.png b/images/matchLocationOfGradientStop.png
index 21dd7f6..6e5c50a 100644
Binary files a/images/matchLocationOfGradientStop.png and b/images/matchLocationOfGradientStop.png differ
diff --git a/images/randomTextColor.png b/images/randomTextColor.png
index 9c44b47..5cde1d1 100644
Binary files a/images/randomTextColor.png and b/images/randomTextColor.png differ
diff --git a/images/relinkFileExtensionExtra.png b/images/relinkFileExtensionExtra.png
index 477ebe9..35cca84 100644
Binary files a/images/relinkFileExtensionExtra.png and b/images/relinkFileExtensionExtra.png differ
diff --git a/images/removeDeletedGlobalColor.png b/images/removeDeletedGlobalColor.png
index 6ff3cf2..2d1c51e 100644
Binary files a/images/removeDeletedGlobalColor.png and b/images/removeDeletedGlobalColor.png differ
diff --git a/images/roundColorValue.png b/images/roundColorValue.png
index 93baf79..d2af426 100644
Binary files a/images/roundColorValue.png and b/images/roundColorValue.png differ
diff --git a/images/roundLocationOfGradientStops.png b/images/roundLocationOfGradientStops.png
index ac6ffc0..912c272 100644
Binary files a/images/roundLocationOfGradientStops.png and b/images/roundLocationOfGradientStops.png differ
diff --git a/images/showColorValues.png b/images/showColorValues.png
index 6508e07..4b0a376 100644
Binary files a/images/showColorValues.png and b/images/showColorValues.png differ
diff --git a/images/shuffleGradientColor.png b/images/shuffleGradientColor.png
index f8adac8..112475b 100644
Binary files a/images/shuffleGradientColor.png and b/images/shuffleGradientColor.png differ
diff --git a/scripts/addSelectedGradientsToSwatch.js b/scripts/addSelectedGradientsToSwatch.js
index bf2f14f..32ba63f 100755
--- a/scripts/addSelectedGradientsToSwatch.js
+++ b/scripts/addSelectedGradientsToSwatch.js
@@ -9,14 +9,14 @@
Notes
Text object and stroke color are not supported.
- In rare cases, if you continue to use the script, it may not work.
- In that case, restart Illustrator and try again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -27,17 +27,20 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0 && app.activeDocument.selection.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
function main() {
- var colors = getColors(app.activeDocument.selection);
+ var items = app.activeDocument.selection;
+ var colors = getColors(items);
+ if (!colors.length) return;
for (var i = 0; i < colors.length; i++) {
+ var color = colors[i];
var name = getGradientName();
- var type = colors[i].gradient.type;
- var stops = getGradientStops(colors[i]);
+ var type = color.gradient.type;
+ var stops = getGradientStops(color);
createGradient(name, type, stops);
}
}
@@ -68,7 +71,8 @@ function getGradientStops(color) {
var stops = [];
var gradients = color.gradient.gradientStops;
for (var i = 0; i < gradients.length; i++) {
- stops.push(gradients[i]);
+ var gradient = gradients[i];
+ stops.push(gradient);
}
return stops;
}
@@ -77,7 +81,8 @@ function getGradientStops(color) {
function getColors(items) {
var colors = [];
for (var i = 0; i < items.length; i++) {
- colors = colors.concat(getGradients(items[i]));
+ var item = items[i];
+ colors = colors.concat(getGradients(item));
}
return colors;
}
@@ -105,8 +110,7 @@ function getGradients(item) {
function isGradient(color) {
- if (color.typename == 'GradientColor') return true;
- return false;
+ return color.typename == 'GradientColor';
}
@@ -127,3 +131,11 @@ function gradientExists(name) {
return false;
}
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/bulkRelink.js b/scripts/bulkRelink.js
new file mode 100755
index 0000000..e64e82a
--- /dev/null
+++ b/scripts/bulkRelink.js
@@ -0,0 +1,525 @@
+/* ===============================================================================================================================================
+ bulkRelink
+
+ Description
+ This script replaces missing links, linked and embedded files in bulk.
+ Since version 2024, the Apply to All checkbox has been removed from the dialog that appears when there are missing link files.
+ As a result, it is no longer possible to replace files in bulk using this dialog.
+
+ Usage
+ 1. Select any missing link, linked or embedded files, run this script from File > Scripts > Other Script...
+ 2. Select a new file.
+ 3. For PDF, select a crop to option and enter a page number from the import options.
+
+ Notes
+ When selecting linked files, select them in the document rather than the Links panel.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
+
+ Requirements
+ Illustrator CS6 or higher
+
+ Version
+ 1.0.0
+
+ Homepage
+ github.com/sky-chaser-high/adobe-illustrator-scripts
+
+ License
+ Released under the MIT license.
+ https://opensource.org/licenses/mit-license.php
+ =============================================================================================================================================== */
+
+(function() {
+ if (app.documents.length && isValidVersion()) main();
+})();
+
+
+function main() {
+ var run = true;
+ var items = app.activeDocument.selection;
+ var links = getPlacedItems(items);
+ links = links.concat(getRasterItems(items));
+ if (!links.length) return;
+
+ var src = File.openDialog();
+ if (!src) return;
+
+ if (isPDFFile(src)) {
+ var dialog = showDialog();
+ dialog.ok.onClick = function() {
+ var crop = getPDFBoxType(dialog.crop.selection);
+ var page = getValue(dialog.page.text);
+ setPDFFileOptions(crop, page);
+ dialog.close();
+ }
+ dialog.cancel.onClick = function() {
+ run = false;
+ dialog.close();
+ }
+ dialog.show();
+ }
+
+ if (run) relink(links, src);
+}
+
+
+function relink(links, src) {
+ for (var i = 0; i < links.length; i++) {
+ var link = links[i];
+ placeLinkedFile(link, src);
+ link.remove();
+ }
+}
+
+
+function placeLinkedFile(link, src) {
+ var item;
+ if (!isCC2015Higher() && isPDFFile(src)) {
+ item = placePDFFile(src);
+ }
+ else {
+ var layer = link.parent;
+ item = layer.placedItems.add();
+ item.file = src;
+ }
+ resizeLinkedFile(item, link);
+}
+
+
+function resizeLinkedFile(item, link) {
+ var angle = getRotationAngle(link);
+ if (angle) item.rotate(angle);
+
+ var ratio = {
+ x: link.width / item.width * 100,
+ y: link.height / item.height * 100
+ };
+ var scale = (ratio.x < ratio.y) ? ratio.x : ratio.y;
+ item.resize(scale, scale);
+
+ item.top = link.top - (link.height / 2) + (item.height / 2);
+ item.left = link.left + (link.width / 2) - (item.width / 2);
+ item.move(link, ElementPlacement.PLACEAFTER);
+}
+
+
+function getRotationAngle(item) {
+ var matrix = item.matrix;
+ var rad = Math.atan2(matrix.mValueB, matrix.mValueA);
+ var deg = rad * 180 / Math.PI;
+ return deg * -1;
+}
+
+
+function setPDFFileOptions(crop, page) {
+ var options = app.preferences.PDFFileOptions;
+ options.pDFCropToBox = crop;
+ if (isCC2015Higher()) {
+ options.pageToOpen = page;
+ options.placeAsLinks = true;
+ }
+ else {
+ var key = 'plugin/PDFImport/PageNumber';
+ app.preferences.setIntegerPreference(key, page);
+ }
+}
+
+
+function placePDFFile(src) {
+ var filename = File.decode(src.fsName);
+ if (isMac()) filename = convertJapanese(filename);
+ runPlacePDFFileAction(filename);
+ return app.activeDocument.placedItems[0];
+}
+
+
+function runPlacePDFFileAction(src) {
+ var set = 'replaceLinkedFile';
+ var action = 'placePDFFile';
+ var code = setActionCode(
+ convertToHexChars(set),
+ convertToHexChars(action),
+ convertToHexChars(src)
+ );
+ var aia = createAction(code, set);
+ try {
+ app.loadAction(aia);
+ app.doScript(action, set);
+ app.unloadAction(set, '');
+ }
+ catch (err) { }
+ aia.remove();
+}
+
+
+function createAction(code, filename) {
+ var dir = Folder('~/Desktop/')
+ var file = File(dir + filename + '.aia');
+ file.open('w');
+ file.write(code);
+ file.close();
+ return file;
+}
+
+
+function setActionCode(set, action, src) {
+ return '\
+ /version 3\
+ /name [ ' + set.length + '\
+ ' + set.hex + '\
+ ]\
+ /isOpen 1\
+ /actionCount 1\
+ /action-1 {\
+ /name [ ' + action.length + '\
+ ' + action.hex + '\
+ ]\
+ /keyIndex 0\
+ /colorIndex 0\
+ /isOpen 1\
+ /eventCount 1\
+ /event-1 {\
+ /useRulersIn1stQuadrant 0\
+ /internalName (adobe_placeDocument)\
+ /localizedName [ 5\
+ 506c616365\
+ ]\
+ /isOpen 1\
+ /isOn 1\
+ /hasDialog 1\
+ /showDialog 0\
+ /parameterCount 7\
+ /parameter-1 {\
+ /key 1885431653\
+ /showInPalette 4294967295\
+ /type (integer)\
+ /value 1\
+ }\
+ /parameter-2 {\
+ /key 1668444016\
+ /showInPalette 4294967295\
+ /type (enumerated)\
+ /name [ 7\
+ 43726f7020546f\
+ ]\
+ /value 4\
+ }\
+ /parameter-3 {\
+ /key 1885823860\
+ /showInPalette 4294967295\
+ /type (integer)\
+ /value 1\
+ }\
+ /parameter-4 {\
+ /key 1851878757\
+ /showInPalette 4294967295\
+ /type (ustring)\
+ /value [ ' + src.length + '\
+ ' + src.hex + '\
+ ]\
+ }\
+ /parameter-5 {\
+ /key 1818848875\
+ /showInPalette 4294967295\
+ /type (boolean)\
+ /value 1\
+ }\
+ /parameter-6 {\
+ /key 1919970403\
+ /showInPalette 4294967295\
+ /type (boolean)\
+ /value 0\
+ }\
+ /parameter-7 {\
+ /key 1953329260\
+ /showInPalette 4294967295\
+ /type (boolean)\
+ /value 0\
+ }\
+ }\
+ }\
+ ';
+}
+
+
+// https://sttk3.com/blog/tips/illustrator/dynamic-generate-action.html
+function convertToHexChars(str) {
+ var hexStr = str.replace(/[0-9A-Za-z!'()*._~-]/g, function(c) {
+ return c.charCodeAt(0).toString(16);
+ });
+ var uri = encodeURIComponent(hexStr).replace(/%/g, '').toLowerCase();
+ return {
+ hex: uri,
+ length: uri.length / 2
+ };
+}
+
+
+function getValue(text) {
+ var twoByteChar = /[!-~]/g;
+ var value = text.replace(twoByteChar, function(str) {
+ return String.fromCharCode(str.charCodeAt(0) - 0xFEE0);
+ });
+ if (isNaN(value) || !value) return 1;
+ return Number(value);
+}
+
+
+// Unicode Combining Character Sequence
+// https://shinkufencer.hateblo.jp/entry/2021/12/04/233000
+// https://bn.dgcr.com/archives/20080707140200.html
+function convertJapanese(text) {
+ var dakuten = '%E3%82%99';
+ var handakuten = '%E3%82%9A';
+ text = convertJapaneseSub(File.encode(text), dakuten, 1);
+ text = convertJapaneseSub(text, handakuten, 2);
+ return File.decode(text);
+}
+function convertJapaneseSub(src, code, count) {
+ src = src.replace(/%E3%82%BF%E3%82%99/g, '%E3%83%80'); // ダだけ特殊処理
+ var texts = src.split(code);
+ for (var i = 0; i < texts.length - 1; i++) {
+ var str = texts[i];
+ if (!str) continue;
+ var body = str.substring(0, str.length - 2);
+ var foot = str.substring(str.length - 2, str.length);
+ var hex = eval('0x' + foot) + count;
+ hex = hex.toString(16).toUpperCase();
+ texts[i] = body + hex;
+ }
+ return texts.join('');
+}
+
+
+function isMac() {
+ return /mac/i.test($.os);
+}
+
+
+function isPDFFile(src) {
+ var extension = getExtension(src);
+ return /pdf/i.test(extension);
+}
+
+
+function getExtension(src) {
+ var filename = File.decode(src.name);
+ var words = filename.split('.');
+ if (words.length < 2) return '';
+ return '.' + words.pop();
+}
+
+
+function getPlacedItems(items) {
+ var links = [];
+ for (var i = 0; i < items.length; i++) {
+ var item = items[i];
+ if (item.typename == 'PlacedItem') {
+ links.push(item);
+ }
+ if (item.typename == 'GroupItem') {
+ links = links.concat(getPlacedItems(item.pageItems));
+ }
+ }
+ return links;
+}
+
+
+function getRasterItems(items) {
+ var links = [];
+ for (var i = 0; i < items.length; i++) {
+ var item = items[i];
+ if (item.typename == 'RasterItem') {
+ links.push(item);
+ }
+ if (item.typename == 'GroupItem') {
+ links = links.concat(getRasterItems(item.pageItems));
+ }
+ }
+ return links;
+}
+
+
+function isCC2015Higher() {
+ var cc2015 = 19;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cc2015) return false;
+ return true;
+}
+
+
+function isValidVersion() {
+ var cs6 = 16;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs6) return false;
+ return true;
+}
+
+
+function getPDFBoxType(item) {
+ switch (item.index) {
+ case 0: return PDFBoxType.PDFBOUNDINGBOX;
+ case 1: return PDFBoxType.PDFARTBOX;
+ case 2: return PDFBoxType.PDFCROPBOX;
+ case 3: return PDFBoxType.PDFTRIMBOX;
+ case 4: return PDFBoxType.PDFBLEEDBOX;
+ case 5: return PDFBoxType.PDFMEDIABOX;
+ }
+}
+
+
+function showDialog() {
+ $.localize = true;
+ var ui = localizeUI();
+
+ var crop = [
+ ui.boundingBox,
+ ui.art,
+ ui.crop,
+ ui.trim,
+ ui.bleed,
+ ui.media
+ ];
+
+ var dialog = new Window('dialog');
+ dialog.text = ui.title;
+ dialog.orientation = 'column';
+ dialog.alignChildren = ['fill', 'top'];
+ dialog.spacing = 10;
+ dialog.margins = 16;
+
+ var group1 = dialog.add('group', undefined, { name: 'group1' });
+ group1.orientation = 'row';
+ group1.alignChildren = ['fill', 'center'];
+ group1.spacing = 10;
+ group1.margins = 0;
+
+ var group2 = group1.add('group', undefined, { name: 'group2' });
+ group2.orientation = 'column';
+ group2.alignChildren = ['right', 'center'];
+ group2.spacing = 18;
+ group2.margins = 0;
+ group2.alignment = ['left', 'center'];
+
+ var statictext1 = group2.add('statictext', undefined, undefined, { name: 'statictext1' });
+ statictext1.text = ui.cropTo;
+
+ var statictext2 = group2.add('statictext', undefined, undefined, { name: 'statictext2' });
+ statictext2.text = ui.page;
+
+ var group3 = group1.add('group', undefined, { name: 'group3' });
+ group3.orientation = 'column';
+ group3.alignChildren = ['left', 'center'];
+ group3.spacing = 10;
+ group3.margins = 0;
+
+ var dropdown1 = group3.add('dropdownlist', undefined, crop, { name: 'dropdown1' });
+ dropdown1.selection = 5;
+ dropdown1.active = true;
+ dropdown1.alignment = ['fill', 'center'];
+
+ var edittext1 = group3.add('edittext', undefined, undefined, { name: 'edittext1' });
+ edittext1.text = '1';
+ edittext1.preferredSize.width = 60;
+
+ var group4 = dialog.add('group', undefined, { name: 'group4' });
+ group4.orientation = 'row';
+ group4.alignChildren = ['right', 'center'];
+ group4.spacing = 10;
+ group4.margins = [0, 10, 0, 0];
+
+ var button1 = group4.add('button', undefined, undefined, { name: 'button1' });
+ button1.text = ui.cancel;
+ button1.preferredSize.width = 90;
+
+ var button2 = group4.add('button', undefined, undefined, { name: 'button2' });
+ button2.text = ui.ok;
+ button2.preferredSize.width = 90;
+
+ edittext1.addEventListener('keydown', setIncreaseDecrease);
+
+ statictext1.addEventListener('click', function() {
+ dropdown1.active = false;
+ dropdown1.active = true;
+ });
+
+ statictext2.addEventListener('click', function() {
+ edittext1.active = false;
+ edittext1.active = true;
+ });
+
+ dialog.crop = dropdown1;
+ dialog.page = edittext1;
+ dialog.cancel = button1;
+ dialog.ok = button2;
+ return dialog;
+}
+
+
+function setIncreaseDecrease(event) {
+ var value = getValue(event.target.text);
+ var keyboard = ScriptUI.environment.keyboardState;
+ var step = keyboard.shiftKey ? 5 : 1;
+ if (event.keyName == 'Up') {
+ value += step;
+ event.target.text = value;
+ event.preventDefault();
+ }
+ if (event.keyName == 'Down') {
+ value -= step;
+ if (value < 1) value = 1;
+ event.target.text = value;
+ event.preventDefault();
+ }
+}
+
+
+function localizeUI() {
+ return {
+ title: {
+ en: 'PDF Import Options',
+ ja: 'PDF 読み込みオプション'
+ },
+ page: {
+ en: 'Page:',
+ ja: 'ページ:'
+ },
+ cropTo: {
+ en: 'Crop to:',
+ ja: 'トリミング:'
+ },
+ boundingBox: {
+ en: 'Bounding Box',
+ ja: 'バウンディングボックス'
+ },
+ art: {
+ en: 'Art',
+ ja: 'アート'
+ },
+ crop: {
+ en: 'Crop',
+ ja: 'トリミング'
+ },
+ trim: {
+ en: 'Trim',
+ ja: '仕上がり'
+ },
+ bleed: {
+ en: 'Bleed',
+ ja: '裁ち落とし'
+ },
+ media: {
+ en: 'Media',
+ ja: 'メディア'
+ },
+ cancel: {
+ en: 'Cancel',
+ ja: 'キャンセル'
+ },
+ ok: {
+ en: 'OK',
+ ja: 'OK'
+ }
+ };
+}
diff --git a/scripts/convertToGlobalColor.js b/scripts/convertToGlobalColor.js
index 16f1349..3d1eede 100755
--- a/scripts/convertToGlobalColor.js
+++ b/scripts/convertToGlobalColor.js
@@ -6,19 +6,19 @@
Usage
Select colors in the Swatches panel, run this script from File > Scripts > Other Script...
- If you don't select them, all colors will target.
+ If not selected, all swatches are converted.
Notes
If there is a swatch with the same name, it will not convert.
When converting a process color to a global color, the order in which the colors display changes because they reregister in the swatch.
- In rare cases, if you continue to use the script, it may not work.
- In that case, restart Illustrator and try again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -29,7 +29,7 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
@@ -147,3 +147,11 @@ function map(value, start1, stop1, start2, stop2) {
return start2 + value2;
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/convertToSpotColor.js b/scripts/convertToSpotColor.js
index 7bde78d..3ba7753 100755
--- a/scripts/convertToSpotColor.js
+++ b/scripts/convertToSpotColor.js
@@ -6,19 +6,19 @@
Usage
Select colors in the Swatches panel, run this script from File > Scripts > Other Script...
- If you don't select them, all colors will target.
+ If not selected, all swatches are converted.
Notes
If there is a swatch with the same name, it will not convert.
When converting a process color to a spot color, the order in which the colors display changes because they reregister in the swatch.
- In rare cases, if you continue to use the script, it may not work.
- In that case, restart Illustrator and try again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -29,7 +29,7 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
@@ -147,3 +147,11 @@ function map(value, start1, stop1, start2, stop2) {
return start2 + value2;
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/createColorChart.js b/scripts/createColorChart.js
index 36c5fbd..7021667 100755
--- a/scripts/createColorChart.js
+++ b/scripts/createColorChart.js
@@ -14,7 +14,7 @@
6. Select Addition or Intensity.
Addition: the value of the steps is added as is.
Intensity: the percentage of the target color is added. It is equivalent to Edit > Edit Colors > Saturate.
- 7. Set the artboard size, color chip size, and units according to your preference.
+ 7. Set the units, artboard size, and color chip size according to your preference.
Notes
Spot color, gradient, and pattern are not supported.
@@ -26,7 +26,7 @@
Illustrator CS6 or higher
Version
- 2.1.0
+ 2.2.0
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -37,12 +37,12 @@
=============================================================================================================================================== */
(function() {
- main();
+ if (isValidVersion()) main();
})();
function main() {
- var items = (app.documents.length > 0) ? app.activeDocument.selection : [];
+ var items = (app.documents.length) ? app.activeDocument.selection : [];
var color = getTargetColor(items);
var dialog = showDialog(color);
@@ -50,7 +50,7 @@ function main() {
var config = getConfiguration(dialog);
if (!verify(config)) return;
- createNewDocument(config.mode, config.unit, config.artboard.width, config.artboard.height);
+ createNewDocument(config.mode, config.units, config.artboard.width, config.artboard.height);
app.executeMenuCommand('fitin');
// target color
@@ -67,14 +67,16 @@ function main() {
function createColorChart(config, item) {
var margin = {
- x: getUnit('2mm', 'pt'),
- y: getUnit('4mm', 'pt')
+ x: convertUnits('2mm', 'pt'),
+ y: convertUnits('4mm', 'pt')
};
+ var artboard = config.artboard;
+ var chip = config.chip;
// Number of chips to create
var count = {
- x: Math.floor((config.artboard.width / 2 - config.chip.width / 2) / (config.chip.width + margin.x)),
- y: Math.floor((config.artboard.height / 2 - config.chip.height / 2) / (config.chip.height + margin.y))
+ x: Math.floor((artboard.width / 2 - chip.width / 2) / (chip.width + margin.x)),
+ y: Math.floor((artboard.height / 2 - chip.height / 2) / (chip.height + margin.y))
};
var baseItem = getColorItem(item);
@@ -209,17 +211,11 @@ function resetColor(item, base, orientation) {
function createColorChip(mode, color, item) {
var layer = app.activeDocument.activeLayer;
var chip = layer.pathItems.rectangle(0, 0, item.width, item.height);
+ chip.stroked = false;
+ chip.filled = true;
+ chip.fillColor = setFillColor(mode, color);
chip.top = item.top;
chip.left = item.left;
- chip.filled = true;
- chip.stroked = false;
-
- if (mode == 'CMYK') {
- chip.fillColor = setCMYKColor(color.color1, color.color2, color.color3, color.color4);
- }
- else {
- chip.fillColor = setRGBColor(color.color1, color.color2, color.color3);
- }
return chip;
}
@@ -266,9 +262,11 @@ function getCenterPosition(width, height) {
x: x1 + document.width / 2,
y: y1 - document.height / 2
};
+ var top = center.y + height / 2;
+ var left = center.x - width / 2;
return {
- top: center.y + height / 2,
- left: center.x - width / 2,
+ top: top,
+ left: left,
width: width,
height: height
};
@@ -343,6 +341,16 @@ function isValidColor(kind) {
}
+function setFillColor(mode, color) {
+ if (mode == 'CMYK') {
+ return setCMYKColor(color.color1, color.color2, color.color3, color.color4);
+ }
+ else {
+ return setRGBColor(color.color1, color.color2, color.color3);
+ }
+}
+
+
function setCMYKColor(c, m, y, k) {
var cyan = c;
var magenta = m;
@@ -393,32 +401,40 @@ function setRGBColor(r, g, b) {
function createNewDocument(mode, unit, width, height) {
+ var title = 'Color Chart';
var preset = new DocumentPreset();
- preset.title = 'Color Chart';
+ preset.title = title;
preset.width = width;
preset.height = height;
- preset.units = getRulerUnits(unit);
preset.colorMode = (mode == 'CMYK') ? DocumentColorSpace.CMYK : DocumentColorSpace.RGB;
+ try {
+ preset.units = setRulerUnits(unit);
+ }
+ catch (err) { }
- var document = app.documents.addDocument('Color Chart', preset);
+ var document = app.documents.addDocument(title, preset);
var artboard = document.artboards[0];
artboard.artboardRect = [0, 0, width, height * -1];
}
-function getRulerUnits(unit) {
- switch (unit) {
- case 'mm': return RulerUnits.Millimeters;
- case 'cm': return RulerUnits.Centimeters;
- case 'inch': return RulerUnits.Inches;
- case 'pt': return RulerUnits.Points;
- case 'px': return RulerUnits.Pixels;
- default: return RulerUnits.Millimeters;
- }
+function round(value) {
+ var digits = 10000;
+ return Math.round(value * digits) / digits;
}
-function getUnit(value, unit) {
+function getValue(text) {
+ var twoByteChar = /[!-~]/g;
+ var value = text.replace(twoByteChar, function(str) {
+ return String.fromCharCode(str.charCodeAt(0) - 0xFEE0);
+ });
+ if (isNaN(value) || !value) return 0;
+ return Number(value);
+}
+
+
+function convertUnits(value, unit) {
try {
return Number(UnitValue(value).as(unit));
}
@@ -428,13 +444,102 @@ function getUnit(value, unit) {
}
+function setRulerUnits(units) {
+ var unitSymbol = getUnitSymbol();
+ switch (units) {
+ case unitSymbol.px: return RulerUnits.Pixels;
+ case unitSymbol.pt: return RulerUnits.Points;
+ case unitSymbol.pc: return RulerUnits.Picas;
+ case unitSymbol.inch: return RulerUnits.Inches;
+ case unitSymbol.mm: return RulerUnits.Millimeters;
+ case unitSymbol.cm: return RulerUnits.Centimeters;
+
+ case unitSymbol.ft: return RulerUnits.Feet;
+ case unitSymbol.yd: return RulerUnits.Yards;
+ case unitSymbol.meter: return RulerUnits.Meters;
+ }
+}
+
+
+function getRulerUnits() {
+ var unit = getUnitSymbol();
+ if (!app.documents.length) return unit.pt;
+
+ var document = app.activeDocument;
+ var src = document.fullName;
+ var ruler = document.rulerUnits;
+ try {
+ switch (ruler) {
+ case RulerUnits.Pixels: return unit.px;
+ case RulerUnits.Points: return unit.pt;
+ case RulerUnits.Picas: return unit.pc;
+ case RulerUnits.Inches: return unit.inch;
+ case RulerUnits.Millimeters: return unit.mm;
+ case RulerUnits.Centimeters: return unit.cm;
+
+ case RulerUnits.Feet: return unit.ft;
+ case RulerUnits.Yards: return unit.yd;
+ case RulerUnits.Meters: return unit.meter;
+ }
+ }
+ catch (err) {
+ switch (xmpRulerUnits(src)) {
+ case 'Feet': return unit.ft;
+ case 'Yards': return unit.yd;
+ case 'Meters': return unit.meter;
+ }
+ }
+ return unit.pt;
+}
+
+
+function xmpRulerUnits(src) {
+ if (!ExternalObject.AdobeXMPScript) {
+ ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
+ }
+ var xmpFile = new XMPFile(src.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ);
+ var xmpPackets = xmpFile.getXMP();
+ var xmp = new XMPMeta(xmpPackets.serialize());
+
+ var namespace = 'http://ns.adobe.com/xap/1.0/t/pg/';
+ var prop = 'xmpTPg:MaxPageSize';
+ var unit = prop + '/stDim:unit';
+
+ var ruler = xmp.getProperty(namespace, unit).value;
+ return ruler;
+}
+
+
+function getUnitSymbol() {
+ return {
+ px: 'px',
+ pt: 'pt',
+ pc: 'pc',
+ inch: 'in',
+ ft: 'ft',
+ yd: 'yd',
+ mm: 'mm',
+ cm: 'cm',
+ meter: 'm'
+ };
+}
+
+
+function isValidVersion() {
+ var cs6 = 16;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs6) return false;
+ return true;
+}
+
+
function getConfiguration(dialog) {
- var color1 = isNaN(Number(dialog.color1.text)) ? 0 : Number(dialog.color1.text);
- var color2 = isNaN(Number(dialog.color2.text)) ? 0 : Number(dialog.color2.text);
- var color3 = isNaN(Number(dialog.color3.text)) ? 0 : Number(dialog.color3.text);
- var color4 = isNaN(Number(dialog.color4.text)) ? 0 : Number(dialog.color4.text);
+ var color1 = getValue(dialog.color1.text);
+ var color2 = getValue(dialog.color2.text);
+ var color3 = getValue(dialog.color3.text);
+ var color4 = getValue(dialog.color4.text);
- var vertical = '', horizontal = '';
+ var vertical, horizontal;
if (dialog.vertical.color1.value) {
vertical = dialog.vertical.color1.text;
@@ -462,20 +567,19 @@ function getConfiguration(dialog) {
horizontal = dialog.horizontal.color4.text;
}
- var step = isNaN(Number(dialog.step.text)) ? 0 : Number(dialog.step.text);
+ var step = getValue(dialog.step.text);
+ var units = dialog.units.selection.toString();
var artboard = {
- width: isNaN(Number(dialog.artboard.width.text)) ? 0 : Number(dialog.artboard.width.text),
- height: isNaN(Number(dialog.artboard.height.text)) ? 0 : Number(dialog.artboard.height.text)
+ width: getValue(dialog.artboard.width.text),
+ height: getValue(dialog.artboard.height.text)
};
var chip = {
- width: isNaN(Number(dialog.chip.width.text)) ? 0 : Number(dialog.chip.width.text),
- height: isNaN(Number(dialog.chip.height.text)) ? 0 : Number(dialog.chip.height.text)
+ width: getValue(dialog.chip.width.text),
+ height: getValue(dialog.chip.height.text)
};
- var unit = dialog.unit.selection.toString();
-
return {
mode: (dialog.cmyk.value) ? 'CMYK' : 'RGB',
color: {
@@ -492,595 +596,501 @@ function getConfiguration(dialog) {
},
kind: (dialog.addition.value) ? 'ADD' : 'INTENSITY',
artboard: {
- width: getUnit(artboard.width + unit, 'pt'),
- height: getUnit(artboard.height + unit, 'pt')
+ width: convertUnits(artboard.width + units, 'pt'),
+ height: convertUnits(artboard.height + units, 'pt')
},
chip: {
- width: getUnit(chip.width + unit, 'pt'),
- height: getUnit(chip.height + unit, 'pt')
+ width: convertUnits(chip.width + units, 'pt'),
+ height: convertUnits(chip.height + units, 'pt')
},
- unit: unit
+ units: units
};
}
-function getInitialValues(unit) {
- switch (unit) {
- case RulerUnits.Millimeters:
- return {
- artboard: { width: 210, height: 297 },
- chip: { width: 20, height: 20 },
- unit: 0
- };
- case RulerUnits.Centimeters:
- return {
- artboard: { width: 21, height: 29.7 },
- chip: { width: 2, height: 2 },
- unit: 1
- };
- case RulerUnits.Inches:
- return {
- artboard: { width: 8.27, height: 11.69 },
- chip: { width: 0.79, height: 0.79 },
- unit: 2
- };
- case RulerUnits.Points:
- return {
- artboard: { width: 595, height: 842 },
- chip: { width: 57, height: 57 },
- unit: 3
- };
- case RulerUnits.Pixels:
- return {
- artboard: { width: 595, height: 842 },
- chip: { width: 57, height: 57 },
- unit: 4
- };
- default:
- return {
- artboard: { width: 210, height: 297 },
- chip: { width: 20, height: 20 },
- unit: 0
- };
+function getInitialValues(units) {
+ var width = convertUnits('210mm', units);
+ var height = convertUnits('297mm', units);
+ var chip = convertUnits('20mm', units);
+ return {
+ artboard: {
+ width: round(width),
+ height: round(height)
+ },
+ chip: {
+ width: round(chip),
+ height: round(chip)
+ },
+ selection: setRulerSelection(units)
+ };
+}
+
+
+function setRulerSelection(units) {
+ try {
+ var ruler = setRulerUnits(units);
+ switch (ruler) {
+ case RulerUnits.Pixels: return 0;
+ case RulerUnits.Points: return 1;
+ case RulerUnits.Picas: return 2;
+ case RulerUnits.Inches: return 3;
+ case RulerUnits.Millimeters: return 6;
+ case RulerUnits.Centimeters: return 7;
+
+ case RulerUnits.Feet: return 4;
+ case RulerUnits.Yards: return 5;
+ case RulerUnits.Meters: return 8;
+ }
+ }
+ catch (err) {
+ var src = app.activeDocument.fullName;
+ switch (xmpRulerUnits(src)) {
+ case 'Feet': return 4;
+ case 'Yards': return 5;
+ case 'Meters': return 8;
+ }
}
}
function verify(config) {
+ $.localize = true;
+ var error = errorMessage();
var message;
+
var color = config.color;
var sum = color.color1 + color.color2 + color.color3 + color.color4;
- if (sum < 1) {
- message = {
- en: 'Enter a color value.',
- ja: 'カラー数値を入力してください。'
- };
- }
- if (config.vertical == '') {
- message = {
- en: 'Select a vertical direction.',
- ja: '上下方向を選択してください。'
- };
+ if (!sum) {
+ message = error.color;
}
-
- if (config.horizontal == '') {
- message = {
- en: 'Select a horizontal direction.',
- ja: '左右方向を選択してください。'
- };
+ if (!config.vertical) {
+ message = error.vertical;
}
-
- if (config.step.x < 1 && config.step.y < 1) {
- message = {
- en: 'Enter a step value.',
- ja: '階調を入力してください。'
- };
+ if (!config.horizontal) {
+ message = error.horizontal;
}
-
- if (config.artboard.width < 1 && config.artboard.height < 1) {
- message = {
- en: 'Enter a artboard size.',
- ja: 'アートボードサイズを入力してください。'
- };
+ if (!config.step.x && !config.step.y) {
+ message = error.step;
}
-
- if (config.chip.width < 1 && config.chip.height < 1) {
- message = {
- en: 'Enter a color chip size.',
- ja: 'カラーチップサイズを入力してください。'
- };
+ if (!config.artboard.width || !config.artboard.height) {
+ message = error.artboard;
+ }
+ if (!config.chip.width || !config.chip.height) {
+ message = error.chip;
}
- $.localize = true;
if (!message) return true;
alert(message);
return false;
}
+function errorMessage() {
+ return {
+ color: {
+ en: 'Enter a color value.',
+ ja: 'カラー数値を入力してください。'
+ },
+ vertical: {
+ en: 'Select a vertical direction.',
+ ja: '垂直方向を選択してください。'
+ },
+ horizontal: {
+ en: 'Select a horizontal direction.',
+ ja: '水平方向を選択してください。'
+ },
+ step: {
+ en: 'Enter a step value.',
+ ja: '階調を入力してください。'
+ },
+ artboard: {
+ en: 'Enter a artboard size.',
+ ja: 'アートボードサイズを入力してください。'
+ },
+ chip: {
+ en: 'Enter a color chip size.',
+ ja: 'カラーチップサイズを入力してください。'
+ }
+ };
+}
+
+
function showDialog(item) {
$.localize = true;
var ui = localizeUI();
+ var CMYK = DocumentColorSpace.CMYK;
+ var RGB = DocumentColorSpace.RGB;
+
var docs = app.documents;
- var ruler = (docs.length > 0) ? app.activeDocument.rulerUnits : RulerUnits.Millimeters;
+ var ruler = (docs.length) ? getRulerUnits() : 'mm';
var initial = getInitialValues(ruler);
- var mode = (docs.length > 0) ? app.activeDocument.documentColorSpace : DocumentColorSpace.CMYK;
- var maxvalue = (mode == DocumentColorSpace.CMYK) ? 100 : 255;
+ var mode = (docs.length) ? app.activeDocument.documentColorSpace : CMYK;
+ var maxvalue = (mode == CMYK) ? 100 : 255;
+ var label = {
+ name1: (mode == CMYK) ? 'C' : 'R',
+ name2: (mode == CMYK) ? 'M' : 'G',
+ name3: (mode == CMYK) ? 'Y' : 'B',
+ name4: (mode == CMYK) ? 'K' : ''
+ };
var dialog = new Window('dialog');
dialog.text = ui.title;
dialog.orientation = 'column';
- dialog.alignChildren = ['left', 'top'];
+ dialog.alignChildren = ['fill', 'top'];
dialog.spacing = 10;
dialog.margins = 16;
- var group1 = dialog.add('group', undefined, { name: 'group1' });
- group1.orientation = 'row';
- group1.alignChildren = ['left', 'center'];
- group1.spacing = 10;
- group1.margins = 0;
-
- var panel1 = group1.add('panel', undefined, undefined, { name: 'panel1' });
+ var panel1 = dialog.add('panel', undefined, undefined, { name: 'panel1' });
panel1.text = ui.mode;
- panel1.preferredSize.width = 340;
panel1.orientation = 'column';
panel1.alignChildren = ['left', 'top'];
panel1.spacing = 10;
panel1.margins = 10;
- var group2 = panel1.add('group', undefined, { name: 'group2' });
- group2.orientation = 'row';
- group2.alignChildren = ['left', 'center'];
- group2.spacing = 10;
- group2.margins = [0, 6, 0, 0];
+ var group1 = panel1.add('group', undefined, { name: 'group1' });
+ group1.orientation = 'row';
+ group1.alignChildren = ['left', 'center'];
+ group1.spacing = 10;
+ group1.margins = [0, 6, 0, 0];
- var radiobutton1 = group2.add('radiobutton', undefined, undefined, { name: 'radiobutton1' });
+ var radiobutton1 = group1.add('radiobutton', undefined, undefined, { name: 'radiobutton1' });
radiobutton1.text = 'CMYK';
- radiobutton1.value = (mode == DocumentColorSpace.CMYK) ? true : false;
+ radiobutton1.value = (mode == CMYK) ? true : false;
- var radiobutton2 = group2.add('radiobutton', undefined, undefined, { name: 'radiobutton2' });
+ var radiobutton2 = group1.add('radiobutton', undefined, undefined, { name: 'radiobutton2' });
radiobutton2.text = 'RGB';
- radiobutton2.value = (mode == DocumentColorSpace.RGB) ? true : false;
+ radiobutton2.value = (mode == RGB) ? true : false;
- var group3 = dialog.add('group', undefined, { name: 'group3' });
- group3.orientation = 'row';
- group3.alignChildren = ['left', 'center'];
- group3.spacing = 10;
- group3.margins = 0;
-
- var panel2 = group3.add('panel', undefined, undefined, { name: 'panel2' });
+ var panel2 = dialog.add('panel', undefined, undefined, { name: 'panel2' });
panel2.text = ui.color;
- panel2.preferredSize.width = 340;
panel2.orientation = 'column';
- panel2.alignChildren = ['right', 'top'];
+ panel2.alignChildren = ['fill', 'top'];
panel2.spacing = 10;
panel2.margins = 10;
- var group4 = panel2.add('group', undefined, { name: 'group4' });
- group4.orientation = 'row';
- group4.alignChildren = ['left', 'center'];
- group4.spacing = 10;
- group4.margins = 0;
+ var group2 = panel2.add('group', undefined, { name: 'group2' });
+ group2.orientation = 'row';
+ group2.alignChildren = ['left', 'center'];
+ group2.spacing = 10;
+ group2.margins = [0, 6, 0, 0];
- var group5 = group4.add('group', undefined, { name: 'group5' });
- group5.preferredSize.width = 14;
- group5.orientation = 'row';
- group5.alignChildren = ['center', 'center'];
- group5.spacing = 10;
- group5.margins = 0;
+ var group3 = group2.add('group', undefined, { name: 'group3' });
+ group3.orientation = 'column';
+ group3.alignChildren = ['center', 'center'];
+ group3.spacing = 18;
+ group3.margins = 0;
+ group3.alignment = ['left', 'center'];
- var statictext1 = group5.add('statictext', undefined, undefined, { name: 'statictext1' });
- statictext1.text = 'C';
+ var statictext1 = group3.add('statictext', undefined, undefined, { name: 'statictext1' });
+ statictext1.text = label.name1;
statictext1.justify = 'center';
- statictext1.preferredSize.width = 15;
+ statictext1.preferredSize.width = 14;
+
+ var statictext2 = group3.add('statictext', undefined, undefined, { name: 'statictext2' });
+ statictext2.text = label.name2;
+ statictext2.justify = 'center';
+ statictext2.preferredSize.width = 14;
+
+ var statictext3 = group3.add('statictext', undefined, undefined, { name: 'statictext3' });
+ statictext3.text = label.name3;
+ statictext3.justify = 'center';
+ statictext3.preferredSize.width = 14;
+
+ var statictext4 = group3.add('statictext', undefined, undefined, { name: 'statictext4' });
+ statictext4.text = label.name4;
+ statictext4.justify = 'center';
+ statictext4.preferredSize.width = 14;
+ statictext4.visible = (mode == CMYK) ? true : false;
+
+ var group4 = group2.add('group', undefined, { name: 'group4' });
+ group4.orientation = 'column';
+ group4.alignChildren = ['fill', 'center'];
+ group4.spacing = 16;
+ group4.margins = 0;
+ group4.alignment = ['fill', 'center'];
var slider1 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider1' });
slider1.minvalue = 0;
slider1.maxvalue = maxvalue;
slider1.value = item.color1;
- slider1.preferredSize.width = 215;
- var edittext1 = group4.add('edittext', undefined, undefined, { name: 'edittext1' });
- edittext1.text = item.color1;
- edittext1.preferredSize.width = 45;
- edittext1.preferredSize.height = 20;
-
- var statictext2 = group4.add('statictext', undefined, undefined, { name: 'statictext2' });
- statictext2.text = '%';
-
- var group6 = panel2.add('group', undefined, { name: 'group6' });
- group6.orientation = 'row';
- group6.alignChildren = ['left', 'center'];
- group6.spacing = 10;
- group6.margins = 0;
-
- var group7 = group6.add('group', undefined, { name: 'group7' });
- group7.preferredSize.width = 14;
- group7.orientation = 'row';
- group7.alignChildren = ['center', 'center'];
- group7.spacing = 10;
- group7.margins = 0;
-
- var statictext3 = group7.add('statictext', undefined, undefined, { name: 'statictext3' });
- statictext3.text = 'M';
- statictext3.justify = 'center';
- statictext3.preferredSize.width = 15;
-
- var slider2 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider2' });
+ var slider2 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider2' });
slider2.minvalue = 0;
slider2.maxvalue = maxvalue;
slider2.value = item.color2;
- slider2.preferredSize.width = 215;
-
- var edittext2 = group6.add('edittext', undefined, undefined, { name: 'edittext2' });
- edittext2.text = item.color2;
- edittext2.preferredSize.width = 45;
- edittext2.preferredSize.height = 20;
- var statictext4 = group6.add('statictext', undefined, undefined, { name: 'statictext4' });
- statictext4.text = '%';
+ var slider3 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider3' });
+ slider3.minvalue = 0;
+ slider3.maxvalue = maxvalue;
+ slider3.value = item.color3;
- var group8 = panel2.add('group', undefined, { name: 'group8' });
- group8.orientation = 'row';
- group8.alignChildren = ['left', 'center'];
- group8.spacing = 10;
- group8.margins = 0;
+ var slider4 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider4' });
+ slider4.minvalue = 0;
+ slider4.maxvalue = maxvalue;
+ slider4.value = item.color4;
+ slider4.visible = (mode == CMYK) ? true : false;
- var group9 = group8.add('group', undefined, { name: 'group9' });
- group9.preferredSize.width = 14;
- group9.orientation = 'row';
- group9.alignChildren = ['center', 'center'];
- group9.spacing = 10;
- group9.margins = 0;
+ var group5 = group2.add('group', undefined, { name: 'group5' });
+ group5.orientation = 'column';
+ group5.alignChildren = ['left', 'center'];
+ group5.spacing = 10;
+ group5.margins = 0;
+ group5.alignment = ['right', 'center'];
- var statictext5 = group9.add('statictext', undefined, undefined, { name: 'statictext5' });
- statictext5.text = 'Y';
- statictext5.justify = 'center';
- statictext5.preferredSize.width = 15;
+ var edittext1 = group5.add('edittext', undefined, undefined, { name: 'edittext1' });
+ edittext1.text = item.color1;
+ edittext1.preferredSize.width = 40;
- var slider3 = group8.add('slider', undefined, undefined, undefined, undefined, { name: 'slider3' });
- slider3.minvalue = 0;
- slider3.maxvalue = maxvalue;
- slider3.value = item.color3;
- slider3.preferredSize.width = 215;
+ var edittext2 = group5.add('edittext', undefined, undefined, { name: 'edittext2' });
+ edittext2.text = item.color2;
+ edittext2.preferredSize.width = 40;
- var edittext3 = group8.add('edittext', undefined, undefined, { name: 'edittext3' });
+ var edittext3 = group5.add('edittext', undefined, undefined, { name: 'edittext3' });
edittext3.text = item.color3;
- edittext3.preferredSize.width = 45;
- edittext3.preferredSize.height = 20;
+ edittext3.preferredSize.width = 40;
- var statictext6 = group8.add('statictext', undefined, undefined, { name: 'statictext6' });
- statictext6.text = '%';
-
- var group10 = panel2.add('group', undefined, { name: 'group10' });
- group10.orientation = 'row';
- group10.alignChildren = ['left', 'center'];
- group10.spacing = 10;
- group10.margins = 0;
+ var edittext4 = group5.add('edittext', undefined, undefined, { name: 'edittext4' });
+ edittext4.text = item.color4;
+ edittext4.preferredSize.width = 40;
+ edittext4.visible = (mode == CMYK) ? true : false;
- var group11 = group10.add('group', undefined, { name: 'group11' });
- group11.preferredSize.width = 14;
- group11.orientation = 'row';
- group11.alignChildren = ['center', 'center'];
- group11.spacing = 10;
- group11.margins = 0;
+ var group6 = group2.add('group', undefined, { name: 'group6' });
+ group6.orientation = 'column';
+ group6.alignChildren = ['left', 'center'];
+ group6.spacing = 18;
+ group6.margins = 0;
+ group6.alignment = ['right', 'center'];
- var statictext7 = group11.add('statictext', undefined, undefined, { name: 'statictext7' });
- statictext7.text = 'K';
- statictext7.justify = 'center';
- statictext7.preferredSize.width = 15;
+ var statictext5 = group6.add('statictext', undefined, undefined, { name: 'statictext5' });
+ statictext5.text = '%';
- var slider4 = group10.add('slider', undefined, undefined, undefined, undefined, { name: 'slider4' });
- slider4.minvalue = 0;
- slider4.maxvalue = maxvalue;
- slider4.value = item.color4;
- slider4.preferredSize.width = 215;
+ var statictext6 = group6.add('statictext', undefined, undefined, { name: 'statictext6' });
+ statictext6.text = '%';
- var edittext4 = group10.add('edittext', undefined, undefined, { name: 'edittext4' });
- edittext4.text = item.color4;
- edittext4.preferredSize.width = 45;
- edittext4.preferredSize.height = 20;
+ var statictext7 = group6.add('statictext', undefined, undefined, { name: 'statictext7' });
+ statictext7.text = '%';
- var statictext8 = group10.add('statictext', undefined, undefined, { name: 'statictext8' });
+ var statictext8 = group6.add('statictext', undefined, undefined, { name: 'statictext8' });
statictext8.text = '%';
+ statictext8.visible = (mode == CMYK) ? true : false;
- var group12 = dialog.add('group', undefined, { name: 'group12' });
- group12.orientation = 'row';
- group12.alignChildren = ['left', 'center'];
- group12.spacing = 10;
- group12.margins = 0;
-
- var panel3 = group12.add('panel', undefined, undefined, { name: 'panel3' });
+ var panel3 = dialog.add('panel', undefined, undefined, { name: 'panel3' });
panel3.text = ui.orientation;
- panel3.preferredSize.width = 340;
panel3.orientation = 'row';
panel3.alignChildren = ['left', 'fill'];
panel3.spacing = 10;
panel3.margins = 10;
- var group13 = panel3.add('group', undefined, { name: 'group13' });
- group13.orientation = 'column';
- group13.alignChildren = ['right', 'center'];
- group13.spacing = 10;
- group13.margins = 0;
+ var group7 = panel3.add('group', undefined, { name: 'group7' });
+ group7.orientation = 'row';
+ group7.alignChildren = ['left', 'center'];
+ group7.spacing = 10;
+ group7.margins = [0, 4, 0, 0];
- var group14 = group13.add('group', undefined, { name: 'group14' });
- group14.orientation = 'row';
- group14.alignChildren = ['left', 'center'];
- group14.spacing = 10;
- group14.margins = [0, 3, 0, 0];
+ var group8 = group7.add('group', undefined, { name: 'group8' });
+ group8.orientation = 'column';
+ group8.alignChildren = ['right', 'center'];
+ group8.spacing = 18;
+ group8.margins = 0;
- var statictext9 = group14.add('statictext', undefined, undefined, { name: 'statictext9' });
+ var statictext9 = group8.add('statictext', undefined, undefined, { name: 'statictext9' });
statictext9.text = ui.vertical;
statictext9.helpTip = ui.tip.vertical;
- var group15 = group13.add('group', undefined, { name: 'group15' });
- group15.orientation = 'row';
- group15.alignChildren = ['left', 'center'];
- group15.spacing = 10;
- group15.margins = [0, 7, 0, 0];
-
- var statictext10 = group15.add('statictext', undefined, undefined, { name: 'statictext10' });
+ var statictext10 = group8.add('statictext', undefined, undefined, { name: 'statictext10' });
statictext10.text = ui.horizontal;
statictext10.helpTip = ui.tip.horizontal;
- var group16 = group13.add('group', undefined, { name: 'group16' });
- group16.orientation = 'row';
- group16.alignChildren = ['left', 'center'];
- group16.spacing = 10;
- group16.margins = [0, 6, 0, 0];
-
- var statictext11 = group16.add('statictext', undefined, undefined, { name: 'statictext11' });
- statictext11.text = ui.step;
+ var statictext11 = group8.add('statictext', undefined, undefined, { name: 'statictext11' });
+ statictext11.text = ui.steps;
- var group17 = panel3.add('group', undefined, { name: 'group17' });
- group17.orientation = 'column';
- group17.alignChildren = ['left', 'center'];
- group17.spacing = 10;
- group17.margins = [0, 10, 0, 0];
+ var group9 = group7.add('group', undefined, { name: 'group9' });
+ group9.orientation = 'column';
+ group9.alignChildren = ['left', 'center'];
+ group9.spacing = 10;
+ group9.margins = [0, 6, 0, 0];
- var group18 = group17.add('group', undefined, { name: 'group18' });
- group18.orientation = 'row';
- group18.alignChildren = ['left', 'center'];
- group18.spacing = 10;
- group18.margins = 0;
+ var group10 = group9.add('group', undefined, { name: 'group10' });
+ group10.orientation = 'row';
+ group10.alignChildren = ['left', 'center'];
+ group10.spacing = 10;
+ group10.margins = 0;
- var radiobutton3 = group18.add('radiobutton', undefined, undefined, { name: 'radiobutton3' });
- radiobutton3.text = 'C';
+ var radiobutton3 = group10.add('radiobutton', undefined, undefined, { name: 'radiobutton3' });
+ radiobutton3.text = label.name1;
radiobutton3.preferredSize.width = 40;
- var radiobutton4 = group18.add('radiobutton', undefined, undefined, { name: 'radiobutton4' });
- radiobutton4.text = 'M';
+ var radiobutton4 = group10.add('radiobutton', undefined, undefined, { name: 'radiobutton4' });
+ radiobutton4.text = label.name2;
radiobutton4.preferredSize.width = 40;
- var radiobutton5 = group18.add('radiobutton', undefined, undefined, { name: 'radiobutton5' });
- radiobutton5.text = 'Y';
+ var radiobutton5 = group10.add('radiobutton', undefined, undefined, { name: 'radiobutton5' });
+ radiobutton5.text = label.name3;
radiobutton5.preferredSize.width = 40;
- var radiobutton6 = group18.add('radiobutton', undefined, undefined, { name: 'radiobutton6' });
- radiobutton6.text = 'K';
+ var radiobutton6 = group10.add('radiobutton', undefined, undefined, { name: 'radiobutton6' });
+ radiobutton6.text = label.name4;
radiobutton6.preferredSize.width = 40;
- var group19 = group17.add('group', undefined, { name: 'group19' });
- group19.orientation = 'row';
- group19.alignChildren = ['left', 'center'];
- group19.spacing = 10;
- group19.margins = [0, 3, 0, 0];
+ var group11 = group9.add('group', undefined, { name: 'group11' });
+ group11.orientation = 'row';
+ group11.alignChildren = ['left', 'center'];
+ group11.spacing = 10;
+ group11.margins = [0, 4, 0, 0];
- var radiobutton7 = group19.add('radiobutton', undefined, undefined, { name: 'radiobutton7' });
- radiobutton7.text = 'C';
+ var radiobutton7 = group11.add('radiobutton', undefined, undefined, { name: 'radiobutton7' });
+ radiobutton7.text = label.name1;
radiobutton7.preferredSize.width = 40;
- var radiobutton8 = group19.add('radiobutton', undefined, undefined, { name: 'radiobutton8' });
- radiobutton8.text = 'M';
+ var radiobutton8 = group11.add('radiobutton', undefined, undefined, { name: 'radiobutton8' });
+ radiobutton8.text = label.name2;
radiobutton8.preferredSize.width = 40;
- var radiobutton9 = group19.add('radiobutton', undefined, undefined, { name: 'radiobutton9' });
- radiobutton9.text = 'Y';
+ var radiobutton9 = group11.add('radiobutton', undefined, undefined, { name: 'radiobutton9' });
+ radiobutton9.text = label.name3;
radiobutton9.preferredSize.width = 40;
- var radiobutton10 = group19.add('radiobutton', undefined, undefined, { name: 'radiobutton10' });
- radiobutton10.text = 'K';
+ var radiobutton10 = group11.add('radiobutton', undefined, undefined, { name: 'radiobutton10' });
+ radiobutton10.text = label.name4;
radiobutton10.preferredSize.width = 40;
- var group20 = group17.add('group', undefined, { name: 'group20' });
- group20.orientation = 'row';
- group20.alignChildren = ['left', 'center'];
- group20.spacing = 10;
- group20.margins = 0;
+ var group12 = group9.add('group', undefined, { name: 'group12' });
+ group12.orientation = 'row';
+ group12.alignChildren = ['left', 'center'];
+ group12.spacing = 10;
+ group12.margins = 0;
- var edittext5 = group20.add('edittext', undefined, undefined, { name: 'edittext5' });
+ var edittext5 = group12.add('edittext', undefined, undefined, { name: 'edittext5' });
edittext5.text = '5';
- edittext5.preferredSize.width = 45;
- edittext5.preferredSize.height = 20;
+ edittext5.preferredSize.width = 40;
- var statictext12 = group20.add('statictext', undefined, undefined, { name: 'statictext12' });
+ var statictext12 = group12.add('statictext', undefined, undefined, { name: 'statictext12' });
statictext12.text = '%';
- var group21 = group20.add('group', undefined, { name: 'group21' });
- group21.orientation = 'row';
- group21.alignChildren = ['left', 'center'];
- group21.spacing = 10;
- group21.margins = [0, 3, 0, 0];
+ var group13 = group12.add('group', undefined, { name: 'group13' });
+ group13.orientation = 'row';
+ group13.alignChildren = ['left', 'center'];
+ group13.spacing = 10;
+ group13.margins = [0, 4, 0, 0];
- var radiobutton11 = group21.add('radiobutton', undefined, undefined, { name: 'radiobutton11' });
+ var radiobutton11 = group13.add('radiobutton', undefined, undefined, { name: 'radiobutton11' });
radiobutton11.text = ui.addition;
radiobutton11.value = true;
- var radiobutton12 = group21.add('radiobutton', undefined, undefined, { name: 'radiobutton12' });
+ var radiobutton12 = group13.add('radiobutton', undefined, undefined, { name: 'radiobutton12' });
radiobutton12.text = ui.intensity;
- var group22 = dialog.add('group', undefined, { name: 'group22' });
- group22.orientation = 'row';
- group22.alignChildren = ['left', 'center'];
- group22.spacing = 10;
- group22.margins = 0;
-
- var panel4 = group22.add('panel', undefined, undefined, { name: 'panel4' });
- panel4.text = ui.option;
- panel4.preferredSize.width = 340;
+ var panel4 = dialog.add('panel', undefined, undefined, { name: 'panel4' });
+ panel4.text = ui.options;
panel4.orientation = 'row';
panel4.alignChildren = ['left', 'fill'];
panel4.spacing = 10;
panel4.margins = 10;
- var group23 = panel4.add('group', undefined, { name: 'group23' });
- group23.orientation = 'column';
- group23.alignChildren = ['right', 'center'];
- group23.spacing = 10;
- group23.margins = 0;
-
- var group24 = group23.add('group', undefined, { name: 'group24' });
- group24.orientation = 'row';
- group24.alignChildren = ['left', 'center'];
- group24.spacing = 10;
- group24.margins = [0, 6, 0, 0];
-
- var statictext13 = group24.add('statictext', undefined, undefined, { name: 'statictext13' });
- statictext13.text = ui.artboard;
-
- var group25 = group23.add('group', undefined, { name: 'group25' });
- group25.orientation = 'row';
- group25.alignChildren = ['left', 'center'];
- group25.spacing = 10;
- group25.margins = [0, 5, 0, 0];
-
- var statictext14 = group25.add('statictext', undefined, undefined, { name: 'statictext14' });
- statictext14.text = ui.chip;
-
- var group26 = group23.add('group', undefined, { name: 'group26' });
- group26.orientation = 'row';
- group26.alignChildren = ['left', 'center'];
- group26.spacing = 10;
- group26.margins = [0, 5, 0, 0];
-
- var statictext15 = group26.add('statictext', undefined, undefined, { name: 'statictext15' });
- statictext15.text = ui.unit;
-
- var group27 = panel4.add('group', undefined, { name: 'group27' });
- group27.orientation = 'column';
- group27.alignChildren = ['left', 'center'];
- group27.spacing = 10;
- group27.margins = [0, 10, 0, 0];
-
- var group28 = group27.add('group', undefined, { name: 'group28' });
- group28.orientation = 'row';
- group28.alignChildren = ['left', 'center'];
- group28.spacing = 10;
- group28.margins = 0;
-
- var statictext16 = group28.add('statictext', undefined, undefined, { name: 'statictext16' });
- statictext16.text = 'W :';
-
- var edittext6 = group28.add('edittext', undefined, undefined, { name: 'edittext6' });
+ var group14 = panel4.add('group', undefined, { name: 'group14' });
+ group14.orientation = 'row';
+ group14.alignChildren = ['left', 'center'];
+ group14.spacing = 10;
+ group14.margins = [0, 4, 0, 0];
+
+ var group15 = group14.add('group', undefined, { name: 'group15' });
+ group15.orientation = 'column';
+ group15.alignChildren = ['right', 'center'];
+ group15.spacing = 18;
+ group15.margins = 0;
+
+ var statictext13 = group15.add('statictext', undefined, undefined, { name: 'statictext13' });
+ statictext13.text = ui.units;
+
+ var statictext14 = group15.add('statictext', undefined, undefined, { name: 'statictext14' });
+ statictext14.text = ui.artboard;
+
+ var statictext15 = group15.add('statictext', undefined, undefined, { name: 'statictext15' });
+ statictext15.text = ui.chip;
+
+ var group16 = group14.add('group', undefined, { name: 'group16' });
+ group16.orientation = 'column';
+ group16.alignChildren = ['left', 'center'];
+ group16.spacing = 10;
+ group16.margins = [0, 1, 0, 0];
+
+ var group17 = group16.add('group', undefined, { name: 'group17' });
+ group17.orientation = 'row';
+ group17.alignChildren = ['left', 'center'];
+ group17.spacing = 10;
+ group17.margins = 0;
+
+ var units = ['px', 'pt', 'pc', 'in', 'ft', 'yd', 'mm', 'cm', 'm'];
+ var dropdown1 = group17.add('dropdownlist', undefined, units, { name: 'dropdown1' });
+ dropdown1.selection = initial.selection;
+ dropdown1.preferredSize.width = 75;
+
+ var group18 = group16.add('group', undefined, { name: 'group18' });
+ group18.orientation = 'row';
+ group18.alignChildren = ['left', 'center'];
+ group18.spacing = 10;
+ group18.margins = 0;
+
+ var statictext16 = group18.add('statictext', undefined, undefined, { name: 'statictext16' });
+ statictext16.text = 'W:';
+
+ var edittext6 = group18.add('edittext', undefined, undefined, { name: 'edittext6' });
edittext6.text = initial.artboard.width;
- edittext6.preferredSize.width = 60;
- edittext6.preferredSize.height = 20;
+ edittext6.preferredSize.width = 75;
- var statictext17 = group28.add('statictext', undefined, undefined, { name: 'statictext17' });
- statictext17.text = 'H :';
+ var statictext17 = group18.add('statictext', undefined, undefined, { name: 'statictext17' });
+ statictext17.text = 'H:';
- var edittext7 = group28.add('edittext', undefined, undefined, { name: 'edittext7' });
+ var edittext7 = group18.add('edittext', undefined, undefined, { name: 'edittext7' });
edittext7.text = initial.artboard.height;
- edittext7.preferredSize.width = 60;
- edittext7.preferredSize.height = 20;
+ edittext7.preferredSize.width = 75;
- var group29 = group27.add('group', undefined, { name: 'group29' });
- group29.orientation = 'row';
- group29.alignChildren = ['left', 'center'];
- group29.spacing = 10;
- group29.margins = 0;
+ var group19 = group16.add('group', undefined, { name: 'group19' });
+ group19.orientation = 'row';
+ group19.alignChildren = ['left', 'center'];
+ group19.spacing = 10;
+ group19.margins = 0;
- var statictext18 = group29.add('statictext', undefined, undefined, { name: 'statictext18' });
- statictext18.text = 'W :';
+ var statictext18 = group19.add('statictext', undefined, undefined, { name: 'statictext18' });
+ statictext18.text = 'W:';
- var edittext8 = group29.add('edittext', undefined, undefined, { name: 'edittext8' });
+ var edittext8 = group19.add('edittext', undefined, undefined, { name: 'edittext8' });
edittext8.text = initial.chip.width;
- edittext8.preferredSize.width = 60;
- edittext8.preferredSize.height = 20;
+ edittext8.preferredSize.width = 75;
- var statictext19 = group29.add('statictext', undefined, undefined, { name: 'statictext19' });
- statictext19.text = 'H :';
+ var statictext19 = group19.add('statictext', undefined, undefined, { name: 'statictext19' });
+ statictext19.text = 'H:';
- var edittext9 = group29.add('edittext', undefined, undefined, { name: 'edittext9' });
+ var edittext9 = group19.add('edittext', undefined, undefined, { name: 'edittext9' });
edittext9.text = initial.chip.height;
- edittext9.preferredSize.width = 60;
- edittext9.preferredSize.height = 20;
-
- var group30 = group27.add('group', undefined, { name: 'group30' });
- group30.orientation = 'row';
- group30.alignChildren = ['left', 'center'];
- group30.spacing = 10;
- group30.margins = 0;
-
- var units = ['mm', 'cm', 'inch', 'pt', 'px'];
- var dropdown1 = group30.add('dropdownlist', undefined, undefined, { name: 'dropdown1', items: units });
- dropdown1.selection = initial.unit;
- dropdown1.preferredSize.width = 60;
- dropdown1.preferredSize.height = 20;
-
- var group31 = dialog.add('group', undefined, { name: 'group31' });
- group31.preferredSize.width = 340;
- group31.orientation = 'row';
- group31.alignChildren = ['right', 'center'];
- group31.spacing = 10;
- group31.margins = 0;
-
- var button1 = group31.add('button', undefined, undefined, { name: 'button1' });
+ edittext9.preferredSize.width = 75;
+
+ var group20 = dialog.add('group', undefined, { name: 'group20' });
+ group20.orientation = 'row';
+ group20.alignChildren = ['right', 'center'];
+ group20.spacing = 10;
+ group20.margins = 0;
+
+ var button1 = group20.add('button', undefined, undefined, { name: 'button1' });
button1.text = ui.cancel;
button1.preferredSize.width = 90;
- var button2 = group31.add('button', undefined, undefined, { name: 'button2' });
+ var button2 = group20.add('button', undefined, undefined, { name: 'button2' });
button2.text = ui.ok;
button2.preferredSize.width = 90;
- switch (mode) {
- case DocumentColorSpace.CMYK:
- radiobutton1.value = true;
- statictext1.text = 'C';
- statictext3.text = 'M';
- statictext5.text = 'Y';
- statictext7.text = 'K';
- radiobutton3.text = 'C';
- radiobutton4.text = 'M';
- radiobutton5.text = 'Y';
- radiobutton7.text = 'C';
- radiobutton8.text = 'M';
- radiobutton9.text = 'Y';
- break;
- case DocumentColorSpace.RGB:
- radiobutton2.value = true;
- statictext1.text = 'R';
- statictext3.text = 'G';
- statictext5.text = 'B';
- statictext7.text = 'K';
- radiobutton3.text = 'R';
- radiobutton4.text = 'G';
- radiobutton5.text = 'B';
- radiobutton7.text = 'R';
- radiobutton8.text = 'G';
- radiobutton9.text = 'B';
- group10.visible = false;
- radiobutton6.visible = false;
- radiobutton10.visible = false;
- break;
- }
-
radiobutton1.onClick = function() {
- statictext1.text = 'C';
- statictext3.text = 'M';
- statictext5.text = 'Y';
- statictext7.text = 'K';
- radiobutton3.text = 'C';
- radiobutton4.text = 'M';
- radiobutton5.text = 'Y';
- radiobutton7.text = 'C';
- radiobutton8.text = 'M';
- radiobutton9.text = 'Y';
- group10.visible = true;
+ statictext1.text = radiobutton3.text = radiobutton7.text = 'C';
+ statictext2.text = radiobutton4.text = radiobutton8.text = 'M';
+ statictext3.text = radiobutton5.text = radiobutton9.text = 'Y';
+ statictext4.text = radiobutton6.text = radiobutton10.text = 'K';
+ statictext4.visible = true;
+ slider4.visible = true;
+ edittext4.visible = true;
+ statictext8.visible = true;
radiobutton6.visible = true;
radiobutton10.visible = true;
maxvalue = 100;
@@ -1091,17 +1101,14 @@ function showDialog(item) {
}
radiobutton2.onClick = function() {
- statictext1.text = 'R';
- statictext3.text = 'G';
- statictext5.text = 'B';
- statictext7.text = 'K';
- radiobutton3.text = 'R';
- radiobutton4.text = 'G';
- radiobutton5.text = 'B';
- radiobutton7.text = 'R';
- radiobutton8.text = 'G';
- radiobutton9.text = 'B';
- group10.visible = false;
+ statictext1.text = radiobutton3.text = radiobutton7.text = 'R';
+ statictext2.text = radiobutton4.text = radiobutton8.text = 'G';
+ statictext3.text = radiobutton5.text = radiobutton9.text = 'B';
+ statictext4.text = radiobutton6.text = radiobutton10.text = '';
+ statictext4.visible = false;
+ slider4.visible = false;
+ edittext4.visible = false;
+ statictext8.visible = false;
radiobutton6.visible = false;
radiobutton10.visible = false;
maxvalue = 255;
@@ -1112,13 +1119,20 @@ function showDialog(item) {
}
dropdown1.onChange = function() {
- var unit = getRulerUnits(dropdown1.selection.toString());
- initial = getInitialValues(unit);
- edittext6.text = initial.artboard.width;
- edittext7.text = initial.artboard.height;
- edittext8.text = initial.chip.width;
- edittext9.text = initial.chip.height;
- dropdown1.selection = initial.unit;
+ var units = dropdown1.selection.toString();
+ var artboard = {
+ width: getValue(edittext6.text),
+ height: getValue(edittext7.text)
+ };
+ var chip = {
+ width: getValue(edittext8.text),
+ height: getValue(edittext9.text)
+ };
+ edittext6.text = round(convertUnits(artboard.width + ruler, units));
+ edittext7.text = round(convertUnits(artboard.height + ruler, units));
+ edittext8.text = round(convertUnits(chip.width + ruler, units));
+ edittext9.text = round(convertUnits(chip.height + ruler, units));
+ ruler = units;
}
statictext1.addEventListener('click', function() {
@@ -1126,17 +1140,17 @@ function showDialog(item) {
edittext1.active = true;
});
- statictext3.addEventListener('click', function() {
+ statictext2.addEventListener('click', function() {
edittext2.active = false;
edittext2.active = true;
});
- statictext5.addEventListener('click', function() {
+ statictext3.addEventListener('click', function() {
edittext3.active = false;
edittext3.active = true;
});
- statictext7.addEventListener('click', function() {
+ statictext4.addEventListener('click', function() {
edittext4.active = false;
edittext4.active = true;
});
@@ -1166,20 +1180,20 @@ function showDialog(item) {
edittext9.active = true;
});
- edittext1.onChange = function() {
- slider1.value = Number(edittext1.text);
+ edittext1.onChanging = function() {
+ slider1.value = getValue(edittext1.text);
}
- edittext2.onChange = function() {
- slider2.value = Number(edittext2.text);
+ edittext2.onChanging = function() {
+ slider2.value = getValue(edittext2.text);
}
- edittext3.onChange = function() {
- slider3.value = Number(edittext3.text);
+ edittext3.onChanging = function() {
+ slider3.value = getValue(edittext3.text);
}
- edittext4.onChange = function() {
- slider4.value = Number(edittext4.text);
+ edittext4.onChanging = function() {
+ slider4.value = getValue(edittext4.text);
}
slider1.onChanging = function() {
@@ -1234,7 +1248,7 @@ function showDialog(item) {
width: edittext8,
height: edittext9
};
- dialog.unit = dropdown1;
+ dialog.units = dropdown1;
dialog.ok = button2;
return dialog;
@@ -1244,7 +1258,7 @@ function showDialog(item) {
function localizeUI() {
return {
title: {
- en: 'Color Chart',
+ en: 'Create Color Chart',
ja: 'カラーチャート'
},
mode: {
@@ -1277,7 +1291,7 @@ function localizeUI() {
ja: '水平方向に増減させる色を\r選択してください。'
}
},
- step: {
+ steps: {
en: 'Steps :',
ja: '増減 :'
},
@@ -1289,10 +1303,14 @@ function localizeUI() {
en: 'Intensity',
ja: '濃度'
},
- option: {
+ options: {
en: 'Options',
ja: 'オプション'
},
+ units: {
+ en: 'Units :',
+ ja: '単位 :'
+ },
artboard: {
en: 'Artboard :',
ja: 'アートボード :'
@@ -1301,10 +1319,6 @@ function localizeUI() {
en: 'Color Chip :',
ja: 'カラーチップ :'
},
- unit: {
- en: 'Units :',
- ja: '単位 :'
- },
cancel: {
en: 'Cancel',
ja: 'キャンセル'
diff --git a/scripts/deleteAllSwatches.js b/scripts/deleteAllSwatches.js
index 8ab589e..8740678 100755
--- a/scripts/deleteAllSwatches.js
+++ b/scripts/deleteAllSwatches.js
@@ -9,14 +9,14 @@
Notes
Delete any swatches in use for the objects as well.
- In rare cases, if you continue to use the script, it may not work.
- In that case, restart Illustrator and try again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -27,7 +27,7 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
@@ -40,3 +40,11 @@ function main() {
var swatches = app.activeDocument.swatches;
swatches.removeAll();
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/exportColorValuesToCSV.js b/scripts/exportColorValuesToCSV.js
index 9900a7a..c854d81 100755
--- a/scripts/exportColorValuesToCSV.js
+++ b/scripts/exportColorValuesToCSV.js
@@ -13,14 +13,14 @@
Export to the desktop.
Prioritize the path object over swatches.
Text object and gradient are not supported.
- In rare cases, if you continue to use the script, it may not work.
- In that case, restart Illustrator and try again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -31,7 +31,7 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
@@ -68,8 +68,9 @@ function getColorList(colors) {
list += ',Swatch name\n';
for (var i = 0; i < colors.length; i++) {
- if (colors[i][0] == undefined) continue;
- list += colors[i].join(',') + '\n';
+ var color = colors[i];
+ if (color[0] == undefined) continue;
+ list += color.join(',') + '\n';
}
return list;
}
@@ -165,3 +166,11 @@ function getMessage() {
}
};
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/extractColorsFromGradient.js b/scripts/extractColorsFromGradient.js
index 1773f58..efc6dd4 100755
--- a/scripts/extractColorsFromGradient.js
+++ b/scripts/extractColorsFromGradient.js
@@ -5,20 +5,20 @@
This script extracts colors as swatches from the gradient stops.
Usage
- Select the path objects or swatches, run this script from File > Scripts > Other Script...
+ Select any path objects or swatches, run this script from File > Scripts > Other Script...
Notes
Prioritize the path object over swatches.
To extract color from swatches, deselect the path objects.
Text object and stroke color are not supported.
- In rare cases, you may not be able to create it.
- In that case, restart Illustrator and run this script again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -29,34 +29,28 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
function main() {
var items = app.activeDocument.selection;
- var colors = [];
-
- if (items.length > 0) {
- colors = getGradientColors(items);
- }
- else {
- colors = getSwatches();
- }
-
+ var colors = getGradientColors(items);
+ if (!colors.length) colors = getSwatches();
addSwatches(colors);
}
function addSwatches(colors) {
for (var i = 0; i < colors.length; i++) {
- var name = getName(colors[i]);
+ var color = colors[i];
+ var name = getName(color);
if (colorExists(name)) continue;
var swatch = app.activeDocument.swatches.add();
try {
swatch.name = name;
- swatch.color = colors[i];
+ swatch.color = color;
}
catch (err) {
swatch.remove();
@@ -68,17 +62,17 @@ function addSwatches(colors) {
function getGradientColors(items) {
var colors = [];
for (var i = 0; i < items.length; i++) {
- switch (items[i].typename) {
+ var item = items[i];
+ switch (item.typename) {
case 'PathItem':
- if (items[i].filled) {
- colors = colors.concat(getColors(items[i].fillColor));
- }
+ if (!item.filled) continue;
+ colors = colors.concat(getColors(item.fillColor));
break;
case 'CompoundPathItem':
- colors = colors.concat(getGradientColors([items[i].pathItems[0]]));
+ colors = colors.concat(getGradientColors([item.pathItems[0]]));
break;
case 'GroupItem':
- colors = colors.concat(getGradientColors(items[i].pageItems));
+ colors = colors.concat(getGradientColors(item.pageItems));
break;
}
}
@@ -90,7 +84,8 @@ function getSwatches() {
var colors = [];
var swatches = app.activeDocument.swatches.getSelected();
for (var i = 0; i < swatches.length; i++) {
- colors = colors.concat(getColors(swatches[i].color));
+ var swatch = swatches[i];
+ colors = colors.concat(getColors(swatch.color));
}
return colors;
}
@@ -101,7 +96,8 @@ function getColors(item) {
if (item.typename == 'GradientColor') {
var gradients = item.gradient.gradientStops;
for (var i = 0; i < gradients.length; i++) {
- colors.push(gradients[i].color);
+ var gradient = gradients[i];
+ colors.push(gradient.color);
}
}
return colors;
@@ -132,9 +128,16 @@ function getName(color) {
function colorExists(name) {
var swatches = app.activeDocument.swatches;
for (var i = 0; i < swatches.length; i++) {
- if (swatches[i].name == name) {
- return true;
- }
+ var swatch = swatches[i];
+ if (swatch.name == name) return true;
}
return false;
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/generateGradientColor.js b/scripts/generateGradientColor.js
index 38a26f6..d157165 100755
--- a/scripts/generateGradientColor.js
+++ b/scripts/generateGradientColor.js
@@ -18,7 +18,7 @@
Illustrator CS4 or higher
Version
- 1.0.1
+ 1.0.2
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -35,18 +35,10 @@
function main() {
var items = app.activeDocument.selection;
- var colors = [];
-
- if (items.length > 0) {
- colors = getColors(items);
- }
- else {
- colors = getSwatches();
- }
-
- if (colors.length > 1) {
- createGradient(colors);
- }
+ var colors = getColors(items);
+ if (!colors.length) colors = getSwatches();
+ if (colors.length < 2) return;
+ createGradient(colors);
}
@@ -81,16 +73,17 @@ function createGradient(colors) {
function getColors(items) {
var colors = [];
for (var i = 0; i < items.length; i++) {
- switch (items[i].typename) {
+ var item = items[i];
+ switch (item.typename) {
case 'PathItem':
- if (!items[i].filled) continue;
- colors = colors.concat(getColorObject(items[i].fillColor));
+ if (!item.filled) continue;
+ colors = colors.concat(getColorObject(item.fillColor));
break;
case 'CompoundPathItem':
- colors = colors.concat(getColors([items[i].pathItems[0]]));
+ colors = colors.concat(getColors([item.pathItems[0]]));
break;
case 'GroupItem':
- colors = colors.concat(getColors(items[i].pageItems));
+ colors = colors.concat(getColors(item.pageItems));
break;
}
}
@@ -102,7 +95,8 @@ function getSwatches() {
var colors = [];
var swatches = app.activeDocument.swatches.getSelected();
for (var i = 0; i < swatches.length; i++) {
- colors = colors.concat(getColorObject(swatches[i].color));
+ var swatch = swatches[i];
+ colors = colors.concat(getColorObject(swatch.color));
}
return colors;
}
diff --git a/scripts/highlightWord.js b/scripts/highlightWord.js
index b4432a9..be2abb3 100755
--- a/scripts/highlightWord.js
+++ b/scripts/highlightWord.js
@@ -2,23 +2,28 @@
highlightWord
Description
- This script highlights the searched words with the fill color.
+ This script highlights the searched string by fill color, swatch or character style.
Both CMYK and RGB colors are supported.
Usage
1. Select any text objects, run this script from File > Scripts > Other Script...
- 2. Enter a word. Regular expressions are supported.
- 3. Use the slider to specify the color if necessary.
+ If no texts are selected, it highlights all texts in the document.
+ 2. Enter a string in the Find field. Regular expressions are supported.
+ 3. To specify a color, enter the color values or use the sliders
+ 4. To specify a swatch, select a swatch name from the list on the Swatches tab and check the Ignore Color Settings checkbox.
+ 5. To specify a character style, select a style name from the list on the Character Styles tab.
+ 6. To specify a paragraph style, select a style name from the list on the Paragraph Styles tab.
Notes
+ Color and swatch cannot be applied at the same time.
In rare cases, the script may not work if you continue to use it.
In this case, restart Illustrator and try again.
Requirements
- Illustrator CS4 or higher
+ Illustrator CS6 or higher
Version
- 1.1.0
+ 1.2.0
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -41,11 +46,17 @@ function main() {
var dialog = showDialog();
dialog.ok.onClick = function() {
- var word = dialog.word.text;
+ var word = dialog.find.text;
if (!word) return dialog.close();
var caps = dialog.caps.value;
- var color = getColor(dialog);
- highlight(word, texts, color, caps);
+ var ignore = dialog.ignore.value;
+ var color = (ignore) ? getSwatch(dialog) : getColor(dialog);
+ var style = {
+ character: getCharacterStyle(dialog),
+ paragraph: getParagraphStyle(dialog)
+ };
+ if (ignore && color) ignore = false;
+ highlight(word, texts, color, style, caps, ignore);
dialog.close();
}
@@ -53,11 +64,11 @@ function main() {
}
-function highlight(word, texts, color, caps) {
+function highlight(word, texts, color, style, caps, override) {
for (var i = 0; i < texts.length; i++) {
var text = texts[i];
var words = getWordIndexes(text.contents, word, caps);
- applyColor(text, words, color);
+ applyColor(text, words, color, style, override);
}
}
@@ -79,37 +90,67 @@ function getWordIndexes(text, word, caps) {
}
-function applyColor(text, words, color) {
+function applyColor(text, words, color, style, override) {
for (var i = 0; i < words.length; i++) {
var word = words[i];
var index = word.index;
for (var j = 0; j < word.length; j++) {
var range = text.textRanges[index + j];
var attributes = range.characterAttributes;
- attributes.fillColor = color;
+ if (color) attributes.fillColor = color;
+ if (style.character) style.character.applyTo(range, override);
+ if (style.paragraph) style.paragraph.applyTo(range, override);
}
}
}
function getColor(dialog) {
- switch (app.activeDocument.documentColorSpace) {
+ var mode = app.activeDocument.documentColorSpace;
+ switch (mode) {
case DocumentColorSpace.CMYK:
var c = Math.round(dialog.color1.value);
var m = Math.round(dialog.color2.value);
var y = Math.round(dialog.color3.value);
var k = Math.round(dialog.color4.value);
- return setCMYK(c, m, y, k);
+ return setCMYKColor(c, m, y, k);
case DocumentColorSpace.RGB:
var r = Math.round(dialog.color1.value);
var g = Math.round(dialog.color2.value);
var b = Math.round(dialog.color3.value);
- return setRGB(r, g, b);
+ return setRGBColor(r, g, b);
}
}
-function setCMYK(c, m, y, k) {
+function getSwatch(dialog) {
+ var swatch = dialog.swatches.selection;
+ if (!swatch) return;
+ var name = swatch.toString();
+ var swatches = app.activeDocument.swatches;
+ return swatches[name].color;
+}
+
+
+function getCharacterStyle(dialog) {
+ var style = dialog.charStyles.selection;
+ if (!style) return;
+ var name = style.toString();
+ var styles = app.activeDocument.characterStyles;
+ return styles[name];
+}
+
+
+function getParagraphStyle(dialog) {
+ var style = dialog.paraStyles.selection;
+ if (!style) return;
+ var name = style.toString();
+ var styles = app.activeDocument.paragraphStyles;
+ return styles[name];
+}
+
+
+function setCMYKColor(c, m, y, k) {
var color = new CMYKColor();
color.cyan = c;
color.magenta = m;
@@ -119,7 +160,7 @@ function setCMYK(c, m, y, k) {
}
-function setRGB(r, g, b) {
+function setRGBColor(r, g, b) {
var color = new RGBColor();
color.red = r;
color.green = g;
@@ -128,7 +169,50 @@ function setRGB(r, g, b) {
}
+function getSwatchNames() {
+ var items = [];
+ var swatches = app.activeDocument.swatches;
+ for (var i = 0; i < swatches.length; i++) {
+ var swatch = swatches[i];
+ try {
+ items.push(swatch.name);
+ }
+ catch (err) { }
+ }
+ return items;
+}
+
+
+function getCharacterStyleNames() {
+ var items = [];
+ var styles = app.activeDocument.characterStyles;
+ for (var i = 0; i < styles.length; i++) {
+ var style = styles[i];
+ try {
+ items.push(style.name);
+ }
+ catch (err) { }
+ }
+ return items;
+}
+
+
+function getParagraphStyleNames() {
+ var items = [];
+ var styles = app.activeDocument.paragraphStyles;
+ for (var i = 0; i < styles.length; i++) {
+ var style = styles[i];
+ try {
+ items.push(style.name);
+ }
+ catch (err) { }
+ }
+ return items;
+}
+
+
function getTextFrames(items) {
+ if (!items.length) return app.activeDocument.textFrames;
var texts = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
@@ -144,14 +228,17 @@ function getTextFrames(items) {
function isValidVersion() {
- var cs4 = 14;
+ var cs6 = 16;
var aiVersion = parseInt(app.version);
- if (aiVersion < cs4) return false;
+ if (aiVersion < cs6) return false;
return true;
}
function showDialog() {
+ $.localize = true;
+ var ui = localizeUI();
+
var mode = app.activeDocument.documentColorSpace;
var CMYK = DocumentColorSpace.CMYK;
var label = {
@@ -162,181 +249,277 @@ function showDialog() {
};
var maxvalue = (mode == CMYK) ? 100 : 255;
- $.localize = true;
- var ui = localizeUI();
-
var dialog = new Window('dialog');
dialog.text = ui.title;
dialog.orientation = 'column';
- dialog.alignChildren = ['left', 'top'];
+ dialog.alignChildren = ['fill', 'top'];
dialog.spacing = 10;
- dialog.margins = 10;
+ dialog.margins = 16;
var group1 = dialog.add('group', undefined, { name: 'group1' });
group1.orientation = 'row';
- group1.alignChildren = ['left', 'top'];
+ group1.alignChildren = ['fill', 'top'];
group1.spacing = 10;
group1.margins = 0;
- group1.alignment = ['fill', 'top'];
-
- var statictext1 = group1.add('statictext', undefined, undefined, { name: 'statictext1' });
- statictext1.text = ui.word;
- statictext1.preferredSize.height = 20;
var group2 = group1.add('group', undefined, { name: 'group2' });
- group2.orientation = 'column';
+ group2.orientation = 'row';
group2.alignChildren = ['left', 'center'];
group2.spacing = 10;
- group2.margins = 0;
+ group2.margins = [0, 4, 0, 0];
+ group2.alignment = ['left', 'top'];
+
+ var statictext1 = group2.add('statictext', undefined, undefined, { name: 'statictext1' });
+ statictext1.text = ui.find;
+
+ var group3 = group1.add('group', undefined, { name: 'group3' });
+ group3.orientation = 'column';
+ group3.alignChildren = ['fill', 'center'];
+ group3.spacing = 10;
+ group3.margins = 0;
+ group3.alignment = ['fill', 'center'];
- var edittext1 = group2.add('edittext', undefined, undefined, { name: 'edittext1' });
+ var edittext1 = group3.add('edittext', undefined, undefined, { name: 'edittext1' });
edittext1.text = '';
- edittext1.preferredSize.width = 185;
edittext1.active = true;
- var checkbox1 = group2.add('checkbox', undefined, undefined, { name: 'checkbox1' });
+ var checkbox1 = group3.add('checkbox', undefined, undefined, { name: 'checkbox1' });
checkbox1.text = ui.caps;
- var panel1 = dialog.add('panel', undefined, undefined, { name: 'panel1' });
- panel1.text = ui.panel;
- panel1.orientation = 'row';
- panel1.alignChildren = ['left', 'top'];
- panel1.spacing = 10;
- panel1.margins = 10;
+ var tpanel1 = dialog.add('tabbedpanel', undefined, undefined, { name: 'tpanel1' });
+ tpanel1.alignChildren = 'fill';
+ tpanel1.margins = 0;
- var group3 = panel1.add('group', undefined, { name: 'group3' });
- group3.orientation = 'column';
- group3.alignChildren = ['center', 'center'];
- group3.spacing = 10;
- group3.margins = [0, 5, 0, 0];
+ var tab1 = tpanel1.add('tab', undefined, undefined, { name: 'tab1' });
+ tab1.text = ui.color;
+ tab1.orientation = 'column';
+ tab1.alignChildren = ['fill', 'top'];
+ tab1.spacing = 10;
+ tab1.margins = 10;
- var color1 = group3.add('statictext', undefined, undefined, { name: 'color1' });
- color1.text = label.name1;
- color1.preferredSize.height = 20;
+ var group4 = tab1.add('group', undefined, { name: 'group4' });
+ group4.orientation = 'row';
+ group4.alignChildren = ['left', 'center'];
+ group4.spacing = 10;
+ group4.margins = 0;
- var color2 = group3.add('statictext', undefined, undefined, { name: 'color2' });
- color2.text = label.name2;
- color2.preferredSize.height = 20;
+ var group5 = group4.add('group', undefined, { name: 'group5' });
+ group5.orientation = 'column';
+ group5.alignChildren = ['center', 'center'];
+ group5.spacing = 18;
+ group5.margins = 0;
+ group5.alignment = ['left', 'center'];
- var color3 = group3.add('statictext', undefined, undefined, { name: 'color3' });
- color3.text = label.name3;
- color3.preferredSize.height = 20;
+ var statictext2 = group5.add('statictext', undefined, undefined, { name: 'statictext2' });
+ statictext2.text = label.name1;
- var color4 = group3.add('statictext', undefined, undefined, { name: 'color4' });
- color4.text = label.name4;
- color4.preferredSize.height = 20;
- color4.visible = (mode == CMYK) ? true : false;
+ var statictext3 = group5.add('statictext', undefined, undefined, { name: 'statictext3' });
+ statictext3.text = label.name2;
- var group4 = panel1.add('group', undefined, { name: 'group4' });
- group4.preferredSize.width = 100;
- group4.orientation = 'column';
- group4.alignChildren = ['left', 'center'];
- group4.spacing = 10;
- group4.margins = [0, 5, 0, 0];
+ var statictext4 = group5.add('statictext', undefined, undefined, { name: 'statictext4' });
+ statictext4.text = label.name3;
+
+ var statictext5 = group5.add('statictext', undefined, undefined, { name: 'statictext5' });
+ statictext5.text = label.name4;
+ statictext5.visible = (mode == CMYK) ? true : false;
+
+ var group6 = group4.add('group', undefined, { name: 'group6' });
+ group6.orientation = 'column';
+ group6.alignChildren = ['fill', 'center'];
+ group6.spacing = 16;
+ group6.margins = 0;
+ group6.alignment = ['fill', 'center'];
- var slider1 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider1' });
+ var slider1 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider1' });
slider1.minvalue = 0;
slider1.maxvalue = maxvalue;
slider1.value = (mode == CMYK) ? 0 : maxvalue;
- slider1.preferredSize.width = 150;
- slider1.preferredSize.height = 20;
- var slider2 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider2' });
+ var slider2 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider2' });
slider2.minvalue = 0;
slider2.maxvalue = maxvalue;
slider2.value = (mode == CMYK) ? maxvalue : 0;
- slider2.preferredSize.width = 150;
- slider2.preferredSize.height = 20;
- var slider3 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider3' });
+ var slider3 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider3' });
slider3.minvalue = 0;
slider3.maxvalue = maxvalue;
slider3.value = (mode == CMYK) ? maxvalue : 0;
- slider3.preferredSize.width = 150;
- slider3.preferredSize.height = 20;
- var slider4 = group4.add('slider', undefined, undefined, undefined, undefined, { name: 'slider4' });
+ var slider4 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider4' });
slider4.minvalue = 0;
slider4.maxvalue = maxvalue;
slider4.value = 0;
- slider4.preferredSize.width = 150;
- slider4.preferredSize.height = 20;
slider4.visible = (mode == CMYK) ? true : false;
- var group5 = panel1.add('group', undefined, { name: 'group5' });
- group5.orientation = 'column';
- group5.alignChildren = ['left', 'center'];
- group5.spacing = 10;
- group5.margins = [0, 5, 0, 0];
-
- var value1 = group5.add('statictext', undefined, undefined, { name: 'value1' });
- value1.text = (mode == CMYK) ? 0 : maxvalue;
- value1.preferredSize.width = 26;
- value1.preferredSize.height = 20;
-
- var value2 = group5.add('statictext', undefined, undefined, { name: 'value2' });
- value2.text = (mode == CMYK) ? maxvalue : 0;
- value2.preferredSize.width = 26;
- value2.preferredSize.height = 20;
-
- var value3 = group5.add('statictext', undefined, undefined, { name: 'value3' });
- value3.text = (mode == CMYK) ? maxvalue : 0;
- value3.preferredSize.width = 26;
- value3.preferredSize.height = 20;
-
- var value4 = group5.add('statictext', undefined, undefined, { name: 'value4' });
- value4.text = '0';
- value4.preferredSize.width = 26;
- value4.preferredSize.height = 20;
- value4.visible = (mode == CMYK) ? true : false;
-
- var group6 = dialog.add('group', undefined, { name: 'group6' });
- group6.orientation = 'row';
- group6.alignChildren = ['left', 'center'];
- group6.spacing = 10;
- group6.margins = 0;
- group6.alignment = ['right', 'top'];
+ var group7 = group4.add('group', undefined, { name: 'group7' });
+ group7.orientation = 'column';
+ group7.alignChildren = ['left', 'center'];
+ group7.spacing = 10;
+ group7.margins = 0;
+ group7.alignment = ['right', 'center'];
+
+ var edittext2 = group7.add('edittext', undefined, undefined, { name: 'edittext2' });
+ edittext2.text = (mode == CMYK) ? 0 : maxvalue;
+ edittext2.preferredSize.width = 40;
+
+ var edittext3 = group7.add('edittext', undefined, undefined, { name: 'edittext3' });
+ edittext3.text = (mode == CMYK) ? maxvalue : 0;
+ edittext3.preferredSize.width = 40;
+
+ var edittext4 = group7.add('edittext', undefined, undefined, { name: 'edittext4' });
+ edittext4.text = (mode == CMYK) ? maxvalue : 0;
+ edittext4.preferredSize.width = 40;
+
+ var edittext5 = group7.add('edittext', undefined, undefined, { name: 'edittext5' });
+ edittext5.text = '0';
+ edittext5.preferredSize.width = 40;
+ edittext5.visible = (mode == CMYK) ? true : false;
+
+ var tab2 = tpanel1.add('tab', undefined, undefined, { name: 'tab2' });
+ tab2.text = ui.swatch;
+ tab2.orientation = 'column';
+ tab2.alignChildren = ['fill', 'top'];
+ tab2.spacing = 10;
+ tab2.margins = 10;
+
+ var listbox1_array = getSwatchNames();
+ var listbox1 = tab2.add('listbox', undefined, undefined, { name: 'listbox1', items: listbox1_array });
+ listbox1.preferredSize.height = 200;
+
+ var tab3 = tpanel1.add('tab', undefined, undefined, { name: 'tab3' });
+ tab3.text = ui.charStyle;
+ tab3.orientation = 'column';
+ tab3.alignChildren = ['fill', 'top'];
+ tab3.spacing = 10;
+ tab3.margins = 10;
+
+ var listbox2_array = getCharacterStyleNames();
+ var listbox2 = tab3.add('listbox', undefined, undefined, { name: 'listbox2', items: listbox2_array });
+ listbox2.preferredSize.height = 200;
+
+ var tab4 = tpanel1.add('tab', undefined, undefined, { name: 'tab4' });
+ tab4.text = ui.paraStyle;
+ tab4.orientation = 'column';
+ tab4.alignChildren = ['fill', 'top'];
+ tab4.spacing = 10;
+ tab4.margins = 10;
+
+ var listbox3_array = getParagraphStyleNames();
+ var listbox3 = tab4.add('listbox', undefined, undefined, { name: 'listbox3', items: listbox3_array });
+ listbox3.preferredSize.height = 200;
+
+ tpanel1.selection = tab1;
+
+ var group8 = dialog.add('group', undefined, { name: 'group8' });
+ group8.orientation = 'row';
+ group8.alignChildren = ['left', 'center'];
+ group8.spacing = 10;
+ group8.margins = 0;
+
+ var checkbox2 = group8.add('checkbox', undefined, undefined, { name: 'checkbox2' });
+ checkbox2.text = ui.ignore;
+
+ var group9 = dialog.add('group', undefined, { name: 'group9' });
+ group9.orientation = 'row';
+ group9.alignChildren = ['right', 'center'];
+ group9.spacing = 10;
+ group9.margins = 0;
+
+ var button1 = group9.add('button', undefined, undefined, { name: 'button1' });
+ button1.text = ui.cancel;
+ button1.preferredSize.width = 90;
+
+ var button2 = group9.add('button', undefined, undefined, { name: 'button2' });
+ button2.text = ui.ok;
+ button2.preferredSize.width = 90;
+
+ listbox1.onChange = function() {
+ var item = listbox1.selection;
+ if (item) checkbox2.value = true;
+ }
- var cancel = group6.add('button', undefined, undefined, { name: 'Cancel' });
- cancel.text = ui.cancel;
- cancel.preferredSize.width = 90;
+ listbox2.onChange = function() {
+ var item = listbox2.selection;
+ if (item) checkbox2.value = true;
+ }
- var ok = group6.add('button', undefined, undefined, { name: 'OK' });
- ok.text = ui.ok;
- ok.preferredSize.width = 90;
+ listbox3.onChange = function() {
+ var item = listbox3.selection;
+ if (item) checkbox2.value = true;
+ }
statictext1.addEventListener('click', function() {
edittext1.active = false;
edittext1.active = true;
});
+ statictext2.addEventListener('click', function() {
+ edittext2.active = false;
+ edittext2.active = true;
+ });
+
+ statictext3.addEventListener('click', function() {
+ edittext3.active = false;
+ edittext3.active = true;
+ });
+
+ statictext4.addEventListener('click', function() {
+ edittext4.active = false;
+ edittext4.active = true;
+ });
+
+ statictext5.addEventListener('click', function() {
+ edittext5.active = false;
+ edittext5.active = true;
+ });
+
slider1.onChanging = function() {
- value1.text = Math.round(slider1.value);
+ edittext2.text = Math.round(slider1.value);
}
slider2.onChanging = function() {
- value2.text = Math.round(slider2.value);
+ edittext3.text = Math.round(slider2.value);
}
slider3.onChanging = function() {
- value3.text = Math.round(slider3.value);
+ edittext4.text = Math.round(slider3.value);
}
slider4.onChanging = function() {
- value4.text = Math.round(slider4.value);
+ edittext5.text = Math.round(slider4.value);
+ }
+
+ edittext2.onChanging = function() {
+ slider1.value = Math.round(edittext2.text);
+ }
+
+ edittext3.onChanging = function() {
+ slider2.value = Math.round(edittext3.text);
}
- cancel.onClick = function() {
+ edittext4.onChanging = function() {
+ slider3.value = Math.round(edittext4.text);
+ }
+
+ edittext5.onChanging = function() {
+ slider4.value = Math.round(edittext5.text);
+ }
+
+ button1.onClick = function() {
dialog.close();
}
- dialog.word = edittext1;
+ dialog.find = edittext1;
dialog.caps = checkbox1;
dialog.color1 = slider1;
dialog.color2 = slider2;
dialog.color3 = slider3;
dialog.color4 = slider4;
- dialog.ok = ok;
+ dialog.swatches = listbox1;
+ dialog.charStyles = listbox2;
+ dialog.paraStyles = listbox3;
+ dialog.ignore = checkbox2;
+ dialog.ok = button2;
return dialog;
}
@@ -347,18 +530,34 @@ function localizeUI() {
en: 'Highlight Word',
ja: '文字列の色を変更'
},
- word: {
- en: 'Word:',
- ja: '単語:'
+ find: {
+ en: 'Find:',
+ ja: '検索文字列:'
},
caps: {
en: 'Match Case',
ja: '大文字と小文字を区別'
},
- panel: {
+ color: {
en: 'Color',
ja: 'カラー'
},
+ swatch: {
+ en: 'Swatches',
+ ja: 'スウォッチ'
+ },
+ charStyle: {
+ en: 'Character Styles',
+ ja: '文字スタイル'
+ },
+ paraStyle: {
+ en: 'Paragraph Styles',
+ ja: '段落スタイル'
+ },
+ ignore: {
+ en: 'Ignore Color Settings',
+ ja: 'カラー設定を無視'
+ },
cancel: {
en: 'Cancel',
ja: 'キャンセル'
diff --git a/scripts/importCSVtoSwatch.js b/scripts/importCSVtoSwatch.js
index 36b3689..d9c91ce 100755
--- a/scripts/importCSVtoSwatch.js
+++ b/scripts/importCSVtoSwatch.js
@@ -29,14 +29,14 @@
The Swatch name is not required.
The leading "#" may be omitted in the case of Hex color.
If the Hex color is 3-digit, it behaves like CSS. (e.g. #F0F becomes #FF00FF.)
- In rare cases, if you continue to use the script, it may not work.
- In that case, restart Illustrator and try again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.2.0
+ 1.2.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -47,7 +47,7 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
@@ -64,9 +64,9 @@ function main() {
}
for (var i = 0; i < colors.length; i++) {
- addSwatch(colors[i]);
+ var color = colors[i];
+ addSwatch(color);
}
-
alert(message.complete);
}
@@ -224,3 +224,11 @@ function getMessage() {
}
};
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/randomTextColor.js b/scripts/randomTextColor.js
index 947592b..2c6da2a 100755
--- a/scripts/randomTextColor.js
+++ b/scripts/randomTextColor.js
@@ -6,9 +6,9 @@
Both CMYK and RGB colors are supported.
Usage
- 1. Select the text objects, run this script from File > Scripts > Other Script...
- 2. Assign the threshold value with the slider.
- 3. Click the Random button to assign a color according to the threshold value.
+ 1. Select any text objects, run this script from File > Scripts > Other Script...
+ 2. Enter the color values or use the sliders to set the threshold.
+ 3. Click the Random button to change the color according to the threshold value.
Notes
If there are many characters, the conversion will take time.
@@ -20,7 +20,7 @@
Illustrator CS4 or higher
Version
- 1.2.1
+ 1.3.0
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -39,6 +39,7 @@ function main() {
var items = app.activeDocument.selection;
var texts = getTextFrames(items);
if (!texts.length) return;
+
var colors = getOriginalColor(texts);
var dialog = showDialog();
@@ -63,6 +64,10 @@ function main() {
handleRandomColor(dialog, texts);
}
+ dialog.notice.onClick = function() {
+ dialog.cancel.notify('onClick');
+ }
+
dialog.cancel.onClick = function() {
revertTextColors(texts, colors);
app.redraw();
@@ -259,216 +264,231 @@ function showDialog() {
var dialog = new Window('dialog');
dialog.text = ui.title;
dialog.orientation = 'column';
- dialog.alignChildren = ['left', 'top'];
+ dialog.alignChildren = ['fill', 'top'];
dialog.spacing = 10;
- dialog.margins = [0, 0, 0, 0];
+ dialog.margins = 0;
var group1 = dialog.add('group', undefined, { name: 'group1' });
group1.orientation = 'row';
- group1.alignChildren = ['left', 'center'];
+ group1.alignChildren = ['fill', 'center'];
group1.spacing = 0;
- group1.margins = [0, 0, 0, 0];
+ group1.margins = 0;
var progressbar1 = group1.add('progressbar', undefined, undefined, { name: 'progressbar1' });
progressbar1.maxvalue = 100;
progressbar1.value = 0;
- progressbar1.preferredSize.width = 343;
progressbar1.preferredSize.height = 2;
- progressbar1.alignment = ['left', 'top'];
var group2 = dialog.add('group', undefined, { name: 'group2' });
group2.orientation = 'column';
- group2.alignChildren = ['left', 'center'];
+ group2.alignChildren = ['fill', 'center'];
group2.spacing = 10;
- group2.margins = [10, 0, 10, 10];
+ group2.margins = [16, 5, 16, 0];
+
+ var panel1 = group2.add('panel', undefined, undefined, { name: 'panel1' });
+ panel1.text = ui.threshold;
+ panel1.orientation = 'column';
+ panel1.alignChildren = ['fill', 'top'];
+ panel1.spacing = 10;
+ panel1.margins = 10;
- var group3 = group2.add('group', undefined, { name: 'group3' });
+ var group3 = panel1.add('group', undefined, { name: 'group3' });
group3.orientation = 'row';
- group3.alignChildren = ['left', 'top'];
+ group3.alignChildren = ['left', 'center'];
group3.spacing = 10;
- group3.margins = 0;
+ group3.margins = [0, 4, 0, 0];
var group4 = group3.add('group', undefined, { name: 'group4' });
- group4.orientation = 'row';
- group4.alignChildren = ['left', 'center'];
- group4.spacing = 10;
+ group4.orientation = 'column';
+ group4.alignChildren = ['center', 'center'];
+ group4.spacing = 18;
group4.margins = 0;
+ group4.alignment = ['left', 'center'];
- var panel1 = group4.add('panel', undefined, undefined, { name: 'panel1' });
- panel1.text = ui.panel;
- panel1.orientation = 'row';
- panel1.alignChildren = ['left', 'top'];
- panel1.spacing = 10;
- panel1.margins = 10;
-
- var group5 = panel1.add('group', undefined, { name: 'group5' });
- group5.orientation = 'column';
- group5.alignChildren = ['center', 'center'];
- group5.spacing = 5;
- group5.margins = 0;
- group5.alignment = ['left', 'center'];
-
- var statictext1 = group5.add('statictext', undefined, undefined, { name: 'color1' });
+ var statictext1 = group4.add('statictext', undefined, undefined, { name: 'statictext1' });
statictext1.text = label.name1;
- statictext1.preferredSize.height = 20;
- var statictext2 = group5.add('statictext', undefined, undefined, { name: 'color2' });
+ var statictext2 = group4.add('statictext', undefined, undefined, { name: 'statictext2' });
statictext2.text = label.name2;
- statictext2.preferredSize.height = 20;
- var statictext3 = group5.add('statictext', undefined, undefined, { name: 'color3' });
+ var statictext3 = group4.add('statictext', undefined, undefined, { name: 'statictext3' });
statictext3.text = label.name3;
- statictext3.preferredSize.height = 20;
- var statictext4 = group5.add('statictext', undefined, undefined, { name: 'color4' });
+ var statictext4 = group4.add('statictext', undefined, undefined, { name: 'statictext4' });
statictext4.text = label.name4;
- statictext4.preferredSize.height = 20;
statictext4.visible = (mode == CMYK) ? true : false;
- var group6 = panel1.add('group', undefined, { name: 'group6' });
- group6.orientation = 'column';
- group6.alignChildren = ['left', 'center'];
- group6.spacing = 4;
- group6.margins = [0, 2, 0, 0];
- group6.alignment = ['left', 'center'];
+ var group5 = group3.add('group', undefined, { name: 'group5' });
+ group5.preferredSize.width = 100;
+ group5.orientation = 'column';
+ group5.alignChildren = ['fill', 'center'];
+ group5.spacing = 16;
+ group5.margins = 0;
+ group5.alignment = ['fill', 'center'];
- var slider1 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider1' });
+ var slider1 = group5.add('slider', undefined, undefined, undefined, undefined, { name: 'slider1' });
slider1.minvalue = 0;
slider1.maxvalue = threshold;
slider1.value = threshold;
- slider1.preferredSize.width = 150;
- slider1.preferredSize.height = 20;
- var slider2 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider2' });
+ var slider2 = group5.add('slider', undefined, undefined, undefined, undefined, { name: 'slider2' });
slider2.minvalue = 0;
slider2.maxvalue = threshold;
slider2.value = threshold;
- slider2.preferredSize.width = 150;
- slider2.preferredSize.height = 20;
- var slider3 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider3' });
+ var slider3 = group5.add('slider', undefined, undefined, undefined, undefined, { name: 'slider3' });
slider3.minvalue = 0;
slider3.maxvalue = threshold;
slider3.value = threshold;
- slider3.preferredSize.width = 150;
- slider3.preferredSize.height = 20;
- var slider4 = group6.add('slider', undefined, undefined, undefined, undefined, { name: 'slider4' });
+ var slider4 = group5.add('slider', undefined, undefined, undefined, undefined, { name: 'slider4' });
slider4.minvalue = 0;
slider4.maxvalue = threshold;
slider4.value = 0;
- slider4.preferredSize.width = 150;
- slider4.preferredSize.height = 20;
slider4.visible = (mode == CMYK) ? true : false;
- var group7 = panel1.add('group', undefined, { name: 'group7' });
- group7.orientation = 'column';
- group7.alignChildren = ['left', 'center'];
- group7.spacing = 5;
- group7.margins = 0;
- group7.alignment = ['left', 'center'];
-
- var statictext5 = group7.add('statictext', undefined, undefined, { name: 'value1' });
- statictext5.text = threshold;
- statictext5.preferredSize.width = 26;
- statictext5.preferredSize.height = 20;
-
- var statictext6 = group7.add('statictext', undefined, undefined, { name: 'value2' });
- statictext6.text = threshold;
- statictext6.preferredSize.width = 26;
- statictext6.preferredSize.height = 20;
-
- var statictext7 = group7.add('statictext', undefined, undefined, { name: 'value3' });
- statictext7.text = threshold;
- statictext7.preferredSize.width = 26;
- statictext7.preferredSize.height = 20;
-
- var statictext8 = group7.add('statictext', undefined, undefined, { name: 'value4' });
- statictext8.text = '0';
- statictext8.preferredSize.width = 26;
- statictext8.preferredSize.height = 20;
- statictext8.visible = (mode == CMYK) ? true : false;
-
- var group8 = group3.add('group', undefined, { name: 'group8' });
- group8.orientation = 'column';
- group8.alignChildren = ['left', 'center'];
- group8.spacing = 10;
- group8.margins = [0, 8, 0, 0];
+ var group6 = group3.add('group', undefined, { name: 'group6' });
+ group6.orientation = 'column';
+ group6.alignChildren = ['left', 'center'];
+ group6.spacing = 10;
+ group6.margins = 0;
+ group6.alignment = ['right', 'center'];
- var button1 = group8.add('button', undefined, undefined, { name: 'random' });
- button1.text = ui.random;
- button1.preferredSize.width = 80;
+ var edittext1 = group6.add('edittext', undefined, undefined, { name: 'edittext1' });
+ edittext1.text = threshold;
+ edittext1.preferredSize.width = 40;
+ edittext1.active = true;
- var button2 = group8.add('button', undefined, undefined, { name: 'ok' });
- button2.text = ui.ok;
- button2.preferredSize.width = 80;
+ var edittext2 = group6.add('edittext', undefined, undefined, { name: 'edittext2' });
+ edittext2.text = threshold;
+ edittext2.preferredSize.width = 40;
- var button3 = group8.add('button', undefined, undefined, { name: 'cancel' });
- button3.text = ui.cancel;
- button3.preferredSize.width = 80;
+ var edittext3 = group6.add('edittext', undefined, undefined, { name: 'edittext3' });
+ edittext3.text = threshold;
+ edittext3.preferredSize.width = 40;
- var group9 = group2.add('group', undefined, { name: 'group9' });
- group9.orientation = 'column';
- group9.alignChildren = ['left', 'center'];
- group9.spacing = 10;
- group9.margins = 0;
+ var edittext4 = group6.add('edittext', undefined, undefined, { name: 'edittext4' });
+ edittext4.text = '0';
+ edittext4.preferredSize.width = 40;
+ edittext4.visible = (mode == CMYK) ? true : false;
+
+ var group7 = dialog.add('group', undefined, { name: 'group7' });
+ group7.orientation = 'column';
+ group7.alignChildren = ['fill', 'center'];
+ group7.spacing = 10;
+ group7.margins = [16, 0, 16, 0];
- var panel2 = group9.add('panel', undefined, undefined, { name: 'panel2' });
- panel2.text = ui.option;
- panel2.preferredSize.width = 231;
+ var panel2 = group7.add('panel', undefined, undefined, { name: 'panel2' });
+ panel2.text = ui.options;
panel2.orientation = 'column';
panel2.alignChildren = ['left', 'top'];
- panel2.spacing = 5;
- panel2.margins = [10, 15, 10, 5];
+ panel2.spacing = 10;
+ panel2.margins = 10;
- var radiobutton1 = panel2.add('radiobutton', undefined, undefined, { name: 'word' });
+ var group8 = panel2.add('group', undefined, { name: 'group8' });
+ group8.orientation = 'row';
+ group8.alignChildren = ['left', 'center'];
+ group8.spacing = 10;
+ group8.margins = [0, 6, 0, 0];
+
+ var radiobutton1 = group8.add('radiobutton', undefined, undefined, { name: 'radiobutton1' });
radiobutton1.text = ui.word;
- radiobutton1.preferredSize.height = 20;
radiobutton1.value = true;
- var radiobutton2 = panel2.add('radiobutton', undefined, undefined, { name: 'character' });
+ var radiobutton2 = group8.add('radiobutton', undefined, undefined, { name: 'radiobutton2' });
radiobutton2.text = ui.character;
- radiobutton2.preferredSize.height = 20;
- var radiobutton3 = panel2.add('radiobutton', undefined, undefined, { name: 'sentence' });
+ var radiobutton3 = group8.add('radiobutton', undefined, undefined, { name: 'radiobutton3' });
radiobutton3.text = ui.sentence;
- radiobutton3.preferredSize.height = 20;
+
+ var group9 = dialog.add('group', undefined, { name: 'group9' });
+ group9.orientation = 'row';
+ group9.alignChildren = ['right', 'center'];
+ group9.spacing = 10;
+ group9.margins = [16, 0, 16, 16];
+
+ var button1 = group9.add('button', undefined, undefined, { name: 'button1' });
+ button1.text = ui.random;
+ button1.preferredSize.width = 90;
+
+ // Work around the problem of not being able to undo with the esc key due to localization.
+ var button0 = group9.add('button', undefined, undefined, { name: 'button0' });
+ button0.text = 'Cancel';
+ button0.preferredSize.width = 20;
+ button0.hide();
+
+ var button2 = group9.add('button', undefined, undefined, { name: 'button2' });
+ button2.text = ui.cancel;
+ button2.preferredSize.width = 90;
+
+ var button3 = group9.add('button', undefined, undefined, { name: 'button3' });
+ button3.text = ui.ok;
+ button3.preferredSize.width = 90;
+
+ statictext1.addEventListener('click', function() {
+ edittext1.active = false;
+ edittext1.active = true;
+ });
+
+ statictext2.addEventListener('click', function() {
+ edittext2.active = false;
+ edittext2.active = true;
+ });
+
+ statictext3.addEventListener('click', function() {
+ edittext3.active = false;
+ edittext3.active = true;
+ });
+
+ statictext4.addEventListener('click', function() {
+ edittext4.active = false;
+ edittext4.active = true;
+ });
slider1.onChanging = function() {
- statictext5.text = Math.round(slider1.value);
+ edittext1.text = Math.round(slider1.value);
}
slider2.onChanging = function() {
- statictext6.text = Math.round(slider2.value);
+ edittext2.text = Math.round(slider2.value);
}
slider3.onChanging = function() {
- statictext7.text = Math.round(slider3.value);
+ edittext3.text = Math.round(slider3.value);
}
slider4.onChanging = function() {
- statictext8.text = Math.round(slider4.value);
+ edittext4.text = Math.round(slider4.value);
}
- button2.onClick = function() {
- dialog.close();
+ edittext1.onChanging = function() {
+ slider1.value = Math.round(edittext1.text);
+ }
+
+ edittext2.onChanging = function() {
+ slider2.value = Math.round(edittext2.text);
+ }
+
+ edittext3.onChanging = function() {
+ slider3.value = Math.round(edittext3.text);
+ }
+
+ edittext4.onChanging = function() {
+ slider4.value = Math.round(edittext4.text);
}
dialog.threshold1 = slider1;
dialog.threshold2 = slider2;
dialog.threshold3 = slider3;
dialog.threshold4 = slider4;
- dialog.label1 = statictext5;
- dialog.label2 = statictext6;
- dialog.label3 = statictext7;
- dialog.label4 = statictext8;
dialog.word = radiobutton1;
dialog.character = radiobutton2;
dialog.sentence = radiobutton3;
dialog.progressbar = progressbar1;
dialog.random = button1;
- dialog.ok = button2;
- dialog.cancel = button3;
+ dialog.notice = button2;
+ dialog.cancel = button0;
+ dialog.ok = button3;
return dialog;
}
@@ -477,14 +497,14 @@ function localizeUI() {
return {
title: {
en: 'Random Text Color',
- ja: 'Random Text Color'
+ ja: 'ランダムに配色'
},
- panel: {
+ threshold: {
en: 'Threshold',
ja: 'しきい値'
},
- option: {
- en: 'Option',
+ options: {
+ en: 'Options',
ja: 'オプション'
},
word: {
diff --git a/scripts/relinkFileExtensionExtra.js b/scripts/relinkFileExtensionExtra.js
index ebaa091..1b58f67 100755
--- a/scripts/relinkFileExtensionExtra.js
+++ b/scripts/relinkFileExtensionExtra.js
@@ -6,14 +6,14 @@
Usage
1. Select any linked files, run this script from File > Scripts > Other Script...
- If no file is selected, it replaces all files in the document.
+ If no files are selected, it replaces all files in the document.
2. Select either file renaming method.
Replace: Enter the current file name in the Find field and a new file name in the Replace field.
It can also be part of the file name. Regular expressions are supported in the Find field.
Add: Enter a string to be added to the prefix, suffix, or both of the original file names.
3. Enter an extension.
If the file extension is the same, enter nothing.
- 4. If you specify PDF as the extension, enter the page number and select the Crop to option.
+ 4. If you specify PDF as the extension, select the Crop to option and enter the page number.
See also: https://helpx.adobe.com/illustrator/using/importing-pdf-files.html
5. To change the folder for the linked file, select a new folder.
If the folder is the same as the original file, select nothing.
@@ -26,10 +26,10 @@
In this case, restart Illustrator and try again.
Requirements
- Illustrator CS4 or higher
+ Illustrator CS6 or higher
Version
- 1.3.0
+ 1.3.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -77,7 +77,8 @@ function relink(items, config) {
continue;
}
if (/pdf/i.test(config.extension)) {
- relinkPDFFile(file, link, config);
+ setPDFFileOptions(config);
+ relinkPDFFile(link, file);
link.remove();
}
else {
@@ -135,28 +136,186 @@ function getExtension(src) {
}
-function relinkPDFFile(pdf, src, config) {
+function setPDFFileOptions(config) {
var options = app.preferences.PDFFileOptions;
- options.pageToOpen = config.page;
- options.placeAsLinks = true;
options.pDFCropToBox = config.crop;
+ if (isCC2015Higher()) {
+ options.pageToOpen = config.page;
+ options.placeAsLinks = true;
+ }
+ else {
+ var key = 'plugin/PDFImport/PageNumber';
+ app.preferences.setIntegerPreference(key, config.page);
+ }
+}
+
+
+function relinkPDFFile(link, src) {
+ var item;
+ if (isCC2015Higher()) {
+ var layer = link.parent;
+ item = layer.placedItems.add();
+ item.file = src;
+ }
+ else {
+ item = placePDFFile(src);
+ }
+ resizePDFFile(item, link);
+}
+
- var layer = src.parent;
- var item = layer.placedItems.add();
- item.file = pdf;
+function placePDFFile(src) {
+ var filename = File.decode(src.fsName);
+ if (isMac()) filename = convertJapanese(filename);
+ runPlacePDFFileAction(filename);
+ return app.activeDocument.placedItems[0];
+}
- var scale = {
- x: src.width / item.width * 100,
- y: src.height / item.height * 100
+
+function resizePDFFile(item, link) {
+ var angle = getRotationAngle(link);
+ if (angle) item.rotate(angle);
+
+ var ratio = {
+ x: link.width / item.width * 100,
+ y: link.height / item.height * 100
};
- item.resize(scale.x, scale.y);
+ var scale = (ratio.x < ratio.y) ? ratio.x : ratio.y;
+ item.resize(scale, scale);
+
+ item.top = link.top - (link.height / 2) + (item.height / 2);
+ item.left = link.left + (link.width / 2) - (item.width / 2);
+ item.move(link, ElementPlacement.PLACEAFTER);
+}
+
+
+function getRotationAngle(item) {
+ var matrix = item.matrix;
+ var rad = Math.atan2(matrix.mValueB, matrix.mValueA);
+ var deg = rad * 180 / Math.PI;
+ return deg * -1;
+}
+
+
+function runPlacePDFFileAction(src) {
+ var set = '_replaceLinkedFile_';
+ var action = 'placePDFFile';
+ var code = setActionCode(
+ convertToHexChars(set),
+ convertToHexChars(action),
+ convertToHexChars(src)
+ );
+ var aia = createAction(code, set);
+ try {
+ app.loadAction(aia);
+ app.doScript(action, set);
+ app.unloadAction(set, '');
+ }
+ catch (err) { }
+ aia.remove();
+}
+
+
+function createAction(code, filename) {
+ var dir = Folder('~/Desktop/')
+ var file = File(dir + filename + '.aia');
+ file.open('w');
+ file.write(code);
+ file.close();
+ return file;
+}
+
+
+function setActionCode(set, action, src) {
+ return '\
+ /version 3\
+ /name [ ' + set.length + '\
+ ' + set.hex + '\
+ ]\
+ /isOpen 1\
+ /actionCount 1\
+ /action-1 {\
+ /name [ ' + action.length + '\
+ ' + action.hex + '\
+ ]\
+ /keyIndex 0\
+ /colorIndex 0\
+ /isOpen 1\
+ /eventCount 1\
+ /event-1 {\
+ /useRulersIn1stQuadrant 0\
+ /internalName (adobe_placeDocument)\
+ /localizedName [ 5\
+ 506c616365\
+ ]\
+ /isOpen 1\
+ /isOn 1\
+ /hasDialog 1\
+ /showDialog 0\
+ /parameterCount 7\
+ /parameter-1 {\
+ /key 1885431653\
+ /showInPalette 4294967295\
+ /type (integer)\
+ /value 1\
+ }\
+ /parameter-2 {\
+ /key 1668444016\
+ /showInPalette 4294967295\
+ /type (enumerated)\
+ /name [ 7\
+ 43726f7020546f\
+ ]\
+ /value 4\
+ }\
+ /parameter-3 {\
+ /key 1885823860\
+ /showInPalette 4294967295\
+ /type (integer)\
+ /value 1\
+ }\
+ /parameter-4 {\
+ /key 1851878757\
+ /showInPalette 4294967295\
+ /type (ustring)\
+ /value [ ' + src.length + '\
+ ' + src.hex + '\
+ ]\
+ }\
+ /parameter-5 {\
+ /key 1818848875\
+ /showInPalette 4294967295\
+ /type (boolean)\
+ /value 1\
+ }\
+ /parameter-6 {\
+ /key 1919970403\
+ /showInPalette 4294967295\
+ /type (boolean)\
+ /value 0\
+ }\
+ /parameter-7 {\
+ /key 1953329260\
+ /showInPalette 4294967295\
+ /type (boolean)\
+ /value 0\
+ }\
+ }\
+ }\
+ ';
+}
- item.top = src.top;
- item.left = src.left;
- item.move(src, ElementPlacement.PLACEAFTER);
- // reset page
- options.pageToOpen = 1;
+// https://sttk3.com/blog/tips/illustrator/dynamic-generate-action.html
+function convertToHexChars(str) {
+ var hexStr = str.replace(/[0-9A-Za-z!'()*._~-]/g, function(c) {
+ return c.charCodeAt(0).toString(16);
+ });
+ var uri = encodeURIComponent(hexStr).replace(/%/g, '').toLowerCase();
+ return {
+ hex: uri,
+ length: uri.length / 2
+ };
}
@@ -178,7 +337,7 @@ function getPlacedItems(items) {
function getValue(text) {
var twoByteChar = /[!-~]/g;
- var value = text.replace(twoByteChar, function (str) {
+ var value = text.replace(twoByteChar, function(str) {
return String.fromCharCode(str.charCodeAt(0) - 0xFEE0);
});
if (isNaN(value) || !value) return 0;
@@ -217,10 +376,18 @@ function isMac() {
}
+function isCC2015Higher() {
+ var cc2015 = 19;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cc2015) return false;
+ return true;
+}
+
+
function isValidVersion() {
- var cs4 = 14;
+ var cs6 = 16;
var aiVersion = parseInt(app.version);
- if (aiVersion < cs4) return false;
+ if (aiVersion < cs6) return false;
return true;
}
@@ -269,8 +436,8 @@ function getPDFBoxType(item) {
switch (item.index) {
case 0: return PDFBoxType.PDFBOUNDINGBOX;
case 1: return PDFBoxType.PDFARTBOX;
- case 2: return (/ja/.test($.locale)) ? PDFBoxType.PDFTRIMBOX : PDFBoxType.PDFCROPBOX;
- case 3: return (/ja/.test($.locale)) ? PDFBoxType.PDFCROPBOX : PDFBoxType.PDFTRIMBOX;
+ case 2: return PDFBoxType.PDFCROPBOX;
+ case 3: return PDFBoxType.PDFTRIMBOX;
case 4: return PDFBoxType.PDFBLEEDBOX;
case 5: return PDFBoxType.PDFMEDIABOX;
}
@@ -329,8 +496,8 @@ function showDialog() {
var crop = [
ui.boundingBox,
ui.art,
- (/ja/.test($.locale)) ? ui.trim : ui.crop,
- (/ja/.test($.locale)) ? ui.crop : ui.trim,
+ ui.crop,
+ ui.trim,
ui.bleed,
ui.media
];
@@ -471,17 +638,17 @@ function showDialog() {
group9.enabled = false;
var statictext7 = group9.add('statictext', undefined, undefined, { name: 'statictext7' });
- statictext7.text = ui.page;
+ statictext7.text = ui.cropTo;
- var edittext6 = group9.add('edittext', undefined, undefined, { name: 'edittext6' });
- edittext6.text = '1';
- edittext6.preferredSize.width = 60;
+ var dropdown1 = group9.add('dropdownlist', undefined, crop, { name: 'dropdown1' });
+ dropdown1.selection = 5;
var statictext8 = group9.add('statictext', undefined, undefined, { name: 'statictext8' });
- statictext8.text = ui.cropTo;
+ statictext8.text = ui.page;
- var dropdown1 = group9.add('dropdownlist', undefined, undefined, { name: 'dropdown1', items: crop });
- dropdown1.selection = 5;
+ var edittext6 = group9.add('edittext', undefined, undefined, { name: 'edittext6' });
+ edittext6.text = '1';
+ edittext6.preferredSize.width = 60;
var panel3 = dialog.add('panel', undefined, undefined, { name: 'panel3' });
panel3.text = ui.folder;
@@ -523,7 +690,7 @@ function showDialog() {
var extension = edittext5.text;
if (/pdf/i.test(extension)) {
group9.enabled = true;
- edittext6.active = true;
+ dropdown1.active = true;
}
else {
group9.enabled = false;
@@ -576,6 +743,11 @@ function showDialog() {
});
statictext7.addEventListener('click', function() {
+ dropdown1.active = false;
+ dropdown1.active = true;
+ });
+
+ statictext8.addEventListener('click', function() {
edittext6.active = false;
edittext6.active = true;
});
@@ -603,8 +775,8 @@ function showDialog() {
dialog.prefix = edittext3;
dialog.suffix = edittext4;
dialog.extension = edittext5;
- dialog.page = edittext6;
dialog.crop = dropdown1;
+ dialog.page = edittext6;
dialog.dir = statictext9;
dialog.ok = button3;
return dialog;
@@ -691,12 +863,12 @@ function localizeUI() {
en: 'Art',
ja: 'アート'
},
- trim: {
- en: 'Trim',
- ja: 'トリミング'
- },
crop: {
en: 'Crop',
+ ja: 'トリミング'
+ },
+ trim: {
+ en: 'Trim',
ja: '仕上がり'
},
bleed: {
diff --git a/scripts/removeDeletedGlobalColor.js b/scripts/removeDeletedGlobalColor.js
index 639a5f8..91af248 100755
--- a/scripts/removeDeletedGlobalColor.js
+++ b/scripts/removeDeletedGlobalColor.js
@@ -1,37 +1,52 @@
/* ===============================================================================================================================================
- removeDeletedGlobalColor.js
+ removeDeletedGlobalColor
- description
- Deletes the Deleted Global Colors displayed in the Separations Preview panel.
+ Description
+ This script deletes the Deleted Global Colors displayed in the Separations Preview panel.
- usage
- 1. Open the Ai file.
- 2. Run this script from File > Scripts > Other Script...
+ Usage
+ Just run this script from File > Scripts > Other Script...
- notes
+ Notes
In rare cases, you may not be able to delete it.
- In that case, restart Illustrator and run this script again.
+ In this case, restart Illustrator and try again.
If you save the file and reopen it, it may be restored.
In this case, there is no way to delete it.
- requirements
+ Requirements
Illustrator CS or higher
- script version
- 1.0.0
- =============================================================================================================================================== */
+ Version
+ 1.0.1
-if (app.documents.length > 0) removeDeletedGlobalColor();
+ Homepage
+ github.com/sky-chaser-high/adobe-illustrator-scripts
+ License
+ Released under the MIT license.
+ https://opensource.org/licenses/mit-license.php
+ =============================================================================================================================================== */
-function removeDeletedGlobalColor() {
- var spotColors = app.activeDocument.spots;
+(function() {
+ if (app.documents.length && isValidVersion()) main();
+})();
- var reg = /Deleted Global Color/i;
- for (var i = spotColors.length - 1; i >= 0; i--) {
- if (reg.test(spotColors[i].name)) {
- spotColors[i].remove();
+function main() {
+ var regex = /Deleted Global Color/i;
+ var colors = app.activeDocument.spots;
+ for (var i = colors.length - 1; i >= 0; i--) {
+ var color = colors[i];
+ if (regex.test(color.name)) {
+ color.remove();
}
}
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/roundColorValue.js b/scripts/roundColorValue.js
index c051dde..c5a9a6e 100755
--- a/scripts/roundColorValue.js
+++ b/scripts/roundColorValue.js
@@ -5,17 +5,17 @@
This script rounds color values. Both fill and stroke colors are supported.
Usage
- Select the objects, run this script from File > Scripts > Other Script...
+ Select any objects, run this script from File > Scripts > Other Script...
Notes
- In rare cases, you may not be able to create it.
- In that case, restart Illustrator and run this script again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -26,7 +26,7 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
@@ -45,15 +45,15 @@ function roundOff(item) {
if (item.stroked) roundColorValue(item.strokeColor);
return;
case 'CompoundPathItem':
- var items = item.pathItems;
- for (var i = 0; i < items.length; i++) {
- roundOff(items[i]);
+ var shapes = item.pathItems;
+ for (var i = 0; i < shapes.length; i++) {
+ roundOff(shapes[i]);
}
return;
case 'GroupItem':
- var items = item.pageItems;
- for (var i = 0; i < items.length; i++) {
- roundOff(items[i]);
+ var shapes = item.pageItems;
+ for (var i = 0; i < shapes.length; i++) {
+ roundOff(shapes[i]);
}
return;
case 'TextFrame':
@@ -79,7 +79,8 @@ function roundColorValue(item) {
case 'GradientColor':
var gradients = item.gradient.gradientStops;
for (var i = 0; i < gradients.length; i++) {
- roundColorValue(gradients[i].color);
+ var gradient = gradient;
+ roundColorValue(gradient.color);
}
return;
case 'GrayColor':
@@ -90,3 +91,11 @@ function roundColorValue(item) {
return;
}
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/roundLocationOfGradientStop.js b/scripts/roundLocationOfGradientStop.js
index b2e54c7..876fb76 100755
--- a/scripts/roundLocationOfGradientStop.js
+++ b/scripts/roundLocationOfGradientStop.js
@@ -6,17 +6,17 @@
Both fill and stroke colors are supported.
Usage
- Select the objects, run this script from File > Scripts > Other Script...
+ Select any objects, run this script from File > Scripts > Other Script...
Notes
- In rare cases, you may not be able to create it.
- In that case, restart Illustrator and run this script again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -27,7 +27,7 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
@@ -46,15 +46,15 @@ function roundOff(item) {
if (item.stroked) roundGradientStops(item.strokeColor);
return;
case 'CompoundPathItem':
- var items = item.pathItems;
- for (var i = 0; i < items.length; i++) {
- roundOff(items[i]);
+ var shapes = item.pathItems;
+ for (var i = 0; i < shapes.length; i++) {
+ roundOff(shapes[i]);
}
return;
case 'GroupItem':
- var items = item.pageItems;
- for (var i = 0; i < items.length; i++) {
- roundOff(items[i]);
+ var shapes = item.pageItems;
+ for (var i = 0; i < shapes.length; i++) {
+ roundOff(shapes[i]);
}
return;
case 'TextFrame':
@@ -70,12 +70,19 @@ function roundOff(item) {
function roundGradientStops(color) {
- if (color.typename == 'GradientColor') {
- var gradients = color.gradient.gradientStops;
- for (var i = 0; i < gradients.length; i++) {
- var gradient = gradients[i];
- gradient.midPoint = Math.round(gradient.midPoint);
- gradient.rampPoint = Math.round(gradient.rampPoint);
- }
+ if (color.typename != 'GradientColor') return;
+ var gradients = color.gradient.gradientStops;
+ for (var i = 0; i < gradients.length; i++) {
+ var gradient = gradients[i];
+ gradient.midPoint = Math.round(gradient.midPoint);
+ gradient.rampPoint = Math.round(gradient.rampPoint);
}
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/showColorValues.js b/scripts/showColorValues.js
index 8520e37..e202b6d 100755
--- a/scripts/showColorValues.js
+++ b/scripts/showColorValues.js
@@ -5,19 +5,19 @@
This script shows color values. Both fill and stroke colors are supported.
Usage
- Select path objects, run this script from File > Scripts > Other Script...
+ Select any path objects, run this script from File > Scripts > Other Script...
Notes
CMYK, RGB, HEX, grayscale, spot color, and pattern are supported.
Text object and gradient are not supported.
- In rare cases, if you continue to use the script, it may not work.
- In that case, restart Illustrator and try again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.1.0
+ 1.1.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -28,18 +28,20 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0 && app.activeDocument.selection.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
function main() {
- var items = getPathItems(app.activeDocument.selection);
- if (!items.length) return;
+ var items = app.activeDocument.selection;
+ var shapes = getPathItems(items);
+ if (!shapes.length) return;
var layer = getLayer('Color Values');
- for (var i = 0; i < items.length; i++) {
- showColorValue(items[i], layer);
+ for (var i = 0; i < shapes.length; i++) {
+ var shape = shapes[i];
+ showColorValue(shape, layer);
}
}
@@ -106,10 +108,11 @@ function getHexValue(r, g, b) {
function getPosition(item, font) {
var margin = 3;
- var x1 = item.visibleBounds[0];
- var y1 = item.visibleBounds[1];
- var x2 = item.visibleBounds[2];
- var y2 = item.visibleBounds[3];
+ var bounds = item.visibleBounds;
+ var x1 = bounds[0];
+ var y1 = bounds[1];
+ var x2 = bounds[2];
+ var y2 = bounds[3];
return [
x1,
y2 - font.size - margin
@@ -118,21 +121,21 @@ function getPosition(item, font) {
function getPathItems(items) {
- var objects = [];
+ var shapes = [];
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (item.typename == 'PathItem') {
- objects.push(item);
+ shapes.push(item);
}
if (item.typename == 'CompoundPathItem') {
- var backside = item.pathItems.length - 1;
- objects.push(item.pathItems[backside]);
+ var end = item.pathItems.length - 1;
+ shapes.push(item.pathItems[end]);
}
if (item.typename == 'GroupItem') {
- objects = objects.concat(getPathItems(item.pageItems));
+ shapes = shapes.concat(getPathItems(item.pageItems));
}
}
- return objects;
+ return shapes;
}
@@ -166,3 +169,11 @@ function layerExists(name) {
return false;
}
}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}
diff --git a/scripts/shuffleGradientColor.js b/scripts/shuffleGradientColor.js
index 446e805..d14edf0 100755
--- a/scripts/shuffleGradientColor.js
+++ b/scripts/shuffleGradientColor.js
@@ -5,19 +5,19 @@
This script shuffles the gradient color.
Usage
- Select the path objects, run this script from File > Scripts > Other Script...
+ Select any path objects, run this script from File > Scripts > Other Script...
Notes
Only a fill color. A stroke color is not supported.
For compound path objects, select them with direct select tool.
- In rare cases, you may not be able to create it.
- In that case, restart Illustrator and run this script again.
+ In rare cases, the script may not work if you continue to use it.
+ In this case, restart Illustrator and try again.
Requirements
Illustrator CS or higher
Version
- 1.0.0
+ 1.0.1
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
@@ -28,19 +28,24 @@
=============================================================================================================================================== */
(function() {
- if (app.documents.length > 0) main();
+ if (app.documents.length && isValidVersion()) main();
})();
function main() {
var items = app.activeDocument.selection;
- for (var i = 0; i < items.length; i++) {
- if (items[i].typename == 'PathItem' && items[i].fillColor.typename == 'GradientColor') {
- var gradient = items[i].fillColor.gradient;
- var colors = getColors(gradient);
- shuffle(colors);
- applyColors(gradient, colors);
- }
+ var shapes = getPathItems(items);
+ if (!shapes.length) return;
+
+ for (var i = 0; i < shapes.length; i++) {
+ var shape = shapes[i];
+ var color = shape.fillColor;
+ if (color.typename != 'GradientColor') continue;
+
+ var gradient = color.gradient;
+ var colors = getColors(gradient);
+ shuffle(colors);
+ applyColors(gradient, colors);
}
}
@@ -72,3 +77,30 @@ function applyColors(gradient, colors) {
gradients[i].color = colors[i];
}
}
+
+
+function getPathItems(items) {
+ var shapes = [];
+ for (var i = 0; i < items.length; i++) {
+ var item = items[i];
+ if (item.typename == 'PathItem') {
+ shapes.push(item);
+ }
+ if (item.typename == 'CompoundPathItem') {
+ var end = item.pathItems.length - 1;
+ shapes.push(item.pathItems[end]);
+ }
+ if (item.typename == 'GroupItem') {
+ shapes = shapes.concat(getPathItems(item.pageItems));
+ }
+ }
+ return shapes;
+}
+
+
+function isValidVersion() {
+ var cs = 11;
+ var aiVersion = parseInt(app.version);
+ if (aiVersion < cs) return false;
+ return true;
+}