Skip to main content
Ten A
Community Expert
Community Expert
February 22, 2022
質問

【自動処理/スクリプト】ワンライナーでなにかする(かもしれない)!!!

  • February 22, 2022
  • 返信数 20.
  • 3848 ビュー

コミュニティーにご参加の皆様、日頃よりご愛顧頂きありがとうございます。先日設置されたJapanラウンジ、見事に限界集落状態です。
ということで、なにか集客につながる企画をどど〜んとやりたいところですが、年度末の昨今ですからそうも行きません(わたしが…)。
ということで、一行でなにか役に立つ事ができるネタスクリプトをご投稿下さい。今更ECMA3なんてやってらんね〜よってご意見はごもっともです。この際ですから、Adobeに関係なくてもいいです。

 

追記 ワンライナーじゃなくてもいいです(^-^;

(500文字ぐらいのつなげちゃう人居そうなのでw)

このトピックへの返信は締め切られました。

返信数 20

りう★
Participant
February 24, 2022

[Illustrator]スウォッチの中からランダムで、パスに塗りを適用する。(「塗りなし」「レジストレーション」は除外)

var doc = app.activeDocument; doc.selection[0].fillColor = doc.swatches[Math.floor(Math.random() * (doc.swatches.length-2))+2].color;

 

Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 25, 2022

面白そうなのでループさせてみました(^-^)/
Adobe Colorでカラー生成してCCライブラリ経由で取り込み、正方形をグリッドで分割しスタイライズの角丸を適用した上で選択状態にしてスクリプトを実行。

for(var i=0;i<app.selection.length;i++)activeDocument.selection[i].fillColor=activeDocument.swatches[Math.floor(Math.random()*(activeDocument.swatches.length-2))+2].color;

 

 

わずか数ステップでここまで来れるのがスクリプトの醍醐味ですね。 

りう★
Participant
February 27, 2022

Ten A さま

分割からの角丸で水玉いいですね!

私も作ってみました。

グラデーションの塗りをランダム適用 → 個別の変形で角度ランダム → ぼかし

手書き風のイメージのときに使ってみようと思います。

 

 

パターンのランダム塗りもおすすめです!

Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 24, 2022

[Illustrator]CCライブラリパネルをアクティブにする。

app.launchExtension("com.adobe.DesignLibraries.angular");
Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 22, 2022

[InDesign/Mac]クリップボードのテキストをAppleScript経由で取り出すサンプル。

 

alert(app.doScript('the clipboard as string', ScriptLanguage.APPLESCRIPT_LANGUAGE ));
Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 22, 2022

[Illustrator]ドキュメント内の全てのオープンパスを検索して閉じる。

for(var i=0,tg=app.activeDocument.pathItems;i<tg.length;i++)if(!tg[i].closed)tg[i].closed=true;

 

akane_neko_tikutiku
Participant
February 22, 2022

実行しているMacがM1Macであるか判断する。Applescript。

 

if ((system attribute "sysa") is equal to 20) then display dialog "これM1 macだわーーー!"

 

何に使うのかって聞かれたら困るな。

Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 25, 2022

InDesignでやってみました〜

app.doScript('if ((system attribute "sysa") is equal to 10) then display dialog "そろそろM1欲しいんっすけどぉ…"', ScriptLanguage.APPLESCRIPT_LANGUAGE );
akane_neko_tikutiku
Participant
February 25, 2022

ワンライナーじゃなくなっちゃうけど、煽るならここまでやるべき。

if ((system attribute "sysa") is equal to 20) then display dialog "これM1 macだわーーー!"
else if ((system attribute "sysa") is equal to 10) then
	display dialog "Intel入ってる?そろそろ買い替えどきじゃないっすか?w"
else if ((system attribute "sysa") is equal to 2) then
	display dialog "いまだにPPCとか物持ちいいですね。化石ですかw"
end if
Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 22, 2022

[InDesign]選択したパラグラフを長体かけて1行に追い込みます。エラートラップしてないので無茶すると横比率0%まで処理しようとしてエラーを吐きます。

var tg=app.selection[0],sc=100;while(tg.lines.length>1){tg.paragraphs[0].horizontalScale=--sc;tg.paragraphs[0].recompose();}
ajabon grinsmith
Community Expert
Community Expert
February 22, 2022

[InDesign]セル内のテキスト選択部分の幅にセル幅を合わせるやつ

 

var sel = app.selection[0], cel = sel.parent; //Text, Cell
cel.width = sel.lines[0].characters[-1].endHorizontalOffset - sel.lines[0].characters[0].horizontalOffset + cel.leftInset + cel.rightInset;

 

 

無理に1行に押し込むと可読性が極端に下がるので、ターゲットの変数宣言の行はノーカウントでいいことにします(勝手に)。

ajabon grinsmith
Community Expert
Community Expert
February 22, 2022

ちなみにテキストの段落にインデントがあると誤差でます(直せよw)

Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 22, 2022

[InDesign] 拡張子がdocxやxlsx、pptxといったオフィスドキュメントを解凍して中の画像を取り出す。

 

 

var f = File.openDialog("");f.fullName.match(/(.+?)\.|docx$|xlsx$|pptx$|zip$|idml|/);var fdr = new Folder(RegExp.$1);if(!fdr.exists) fdr.create();app.unpackageUCF(f, fdr);

 

 

Subi Omu
Participating Frequently
February 22, 2022

[InDesign] 分割禁止をコンテキストメニューに追加

app.menus.item("文字のコンテキストメニュー").menuItems.add(app.menuActions.item("分割禁止"));

使いどころ:分割禁止をよく使う人向け。

分割禁止したい単語をダブルクリックで選択→右クリックで出てくるコンテキストメニューで追加した分割禁止を選択する。

 

Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 25, 2022

起動時に読み込むようにしました〜(^-^;

Ten A
Community Expert
Ten ACommunity Expert作成者
Community Expert
February 22, 2022

[Illustrator/InDesign]選択したテキストの内容を逆並びにする。

app.selection[0].contents=app.selection[0].contents.split("").reverse().join("");

 

Subi Omu
Participating Frequently
February 22, 2022

[InDesign]InDesignに配置した画像を座標指定で移動する。

var pdfObj = app.activeDocument.allGraphics; for(i=0; i<pdfObj.length; i++) {pdfObj[i].parent.move([0, 10]);}

使いどころ:InDesignを台紙にしてページサイズのPDFを貼り込んだけれど、位置を微調整したいという時。

Subi Omu
Participating Frequently
February 22, 2022

1行に書き換えないとこうです。このほうが見やすいですね。

var pdfObj = app.activeDocument.allGraphics; 
for(i=0; i<pdfObj.length; i++) {
    pdfObj[i].parent.move([0, 10]);
    }