Skip to main content
Ten A
Community Expert
Community Expert
Feb 22, 2022 3:09 AM UTC
Question

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

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

 

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

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

This topic is closed to new replies. Start a new post to keep the conversation going.

40 replies

Ten A
Community Expert
Ten ACommunity ExpertAuthor
Community Expert
Jan 11, 2023 5:34 AM UTC

InDesignの段落コンポーザーを粛清するやつ

 

for(var i=0;i<app.activeDocument.stories.length;i++) app.activeDocument.stories[i].composer="Adobe 日本語単数行コンポーザー";

 

テーブルは別途処理要です。

Translate
Ten A
Community Expert
Ten ACommunity ExpertAuthor
Community Expert
Nov 16, 2022 11:19 AM UTC

[DeviceCentral]DeveiceCentralでZIP圧縮(^-^;

var gZip = new ZIPFile;gZip.open("~/Desktop/test.zip");gZip.addFile("test.pdf","~/Desktop/test.pdf","");gZip.close();
Translate
ajabon grinsmith
Community Expert
Community Expert
Oct 6, 2022 6:28 AM UTC

[InDesign]

使用中/未使用に関わらず、合成フォント中の Pro / Pr5 / Pr6 書体を Pr6N に変更するやつ。当該フォントがインストールされている必要あり。

var doc = app.activeDocument;
var rptAry = [];
var cFonts = doc.compositeFonts;
for(var i = 1; i < cFonts.length; i++){
    var cfEntry = cFonts[i].compositeFontEntries;
    for(var j = 0; j < cfEntry.length; j++){
        if(cfEntry[j].appliedFont.match(/ Pr[o56]$/)){
            var pr6n = app.fonts.itemByName(cfEntry[j].appliedFont.replace(/Pr[o56]$/, "Pr6N"));
            if(pr6n.isValid){
                try{
                    cfEntry[j].appliedFont = pr6n.fontFamily;
                    }catch(e){
                        rptAry.push(cFonts.name + ":" + cfEntry.name + ":" + cfEntry[j].appliedFont + " " + cfEntry[j].fontStyle);
                        }
                }
            }
        }
    }

if(rptAry.length){
    alert("以下のフォントは謎エラーで置換できませんでした\n" + rptAry.join("\n"));
    }
Translate
Ten A
Community Expert
Ten ACommunity ExpertAuthor
Community Expert
May 27, 2022 3:39 AM UTC

[Illustrator] 選択した図形に「効果→パスの変形→ジグザグ...」を適用。

 

var xmlstring = '<LiveEffect name="Adobe Zigzag"><Dict data="R roundness 1 R absoluteness 1 R relAmount 5 R ridges 10 R amount 20 " /></LiveEffect>';app.selection[0].applyEffect(xmlstring);


roundness 0→1でポイントが滑らかに、amountの数値が大きさ、ridgesが折り返し数になっています。

Translate
kawamoto_α
Inspiring
May 27, 2022 5:05 AM UTC

ちょっと改造して選択した直線がサインカーブになるやつ

var xmlstring = '<LiveEffect name="Adobe Zigzag"><Dict data="R roundness 0.727 R absoluteness 1 R relAmount 5 R ridges 10 R amount 20 " /></LiveEffect>';app.selection[0].applyEffect(xmlstring);
Translate
Ten A
Community Expert
Ten ACommunity ExpertAuthor
Community Expert
Apr 26, 2022 6:38 AM UTC

[InDesign] エフェクトの適用
ドロップシャドウの例でございます。オブジェクトを選択した状態で実行してください(^-^)/

with(app.selection[0].transparencySettings.dropShadowSettings){mode=ShadowMode.DROP;effectColor =app.documents[0].swatches[3];angle=135;}
Translate
monokano
Community Expert
Community Expert
Mar 29, 2022 3:45 AM UTC

[InDesign] 「再リンク時に画像サイズを保持」をトグルする

app.imagePreferences.preserveBounds = !app.imagePreferences.preserveBounds;
Translate
ajabon grinsmith
Community Expert
Community Expert
Mar 29, 2022 3:06 AM UTC

[InDesign] 「コピー元のレイヤーにペースト」チェックをトグルする

app.menuActions.item('$ID/Set Paste Remembers').invoke();

あれ、「レイヤーを記憶してペースト」 ?

Translate
ajabon grinsmith
Community Expert
Community Expert
Mar 29, 2022 4:58 AM UTC

これでもおなじ。

 app.clipboardPreferences.pasteRemembersLayers ^=1;

ふるいバージョンでは「レイヤーを記憶してペースト」だったのが、

近年Illustratorに揃えて「コピー元のレイヤーにペースト」と名称が改まったらしいっぽかったです。

Translate
Ten A
Community Expert
Ten ACommunity ExpertAuthor
Community Expert
Mar 26, 2022 7:38 AM UTC

[Illustrator]アートボードサイズの四角形を作成します。

var b = app.activeDocument.artboards[0].artboardRect;app.activeDocument.pathItems.rectangle(b[0],b[1],b[2],-b[3]);

 

 

ラウンジに人集まりませんねぇ…(^-^;

 

Translate
ajabon grinsmith
Community Expert
Community Expert
Feb 28, 2022 5:42 AM UTC

正規表現検索置換クエリをスクリプトのファイル名で引っ掛けて呼び出して実行、

実行後に正規表現検索置換の設定をスクリプト実行前に戻しておくやつ(説明が長い)。

検索置換対象はとりあえず選択テキスト(selection[0])としてあります。

 

 

//スクリプト名と同名のGREPクエリをロードして実行後にロード前の設定に戻すやつ
var queryName = decodeURI(app.activeScript.name).replace(/\.jsx$/i, ""); //実行しているスクリプトの名前
var findGrepPrefOrg = app.findGrepPreferences.properties; //検索設定・置換設定の元
var changeGrepPrefOrg = app.changeGrepPreferences.properties;
app.loadFindChangeQuery (queryName, SearchModes.GREP_SEARCH); //クエリ召喚、実行
app.activeDocument.selection[0].changeGrep();
app.findGrepPreferences.properties = findGrepPrefOrg; //検索設定・置換設定モドス
app.changeGrepPreferences.properties = changeGrepPrefOrg;

 

 

 

Translate
Participant
Feb 25, 2022 1:47 AM UTC

[InDesign]InDesignの選択したオブジェクトを自身と同じ幅1個分左に移動する

app.activeDocument.selection[0].geometricBounds = function(SEL,DM){return function(gb){return {'L':[gb[0],gb[1]*2-gb[3], gb[2],gb[1]],'R':[gb[0],gb[3],gb[2],gb[3]*2-gb[1]],'U':[gb[0]*2-gb[2],gb[1],gb[0],gb[3]],'D':[gb[2],gb[1],gb[2]*2-gb[0],gb[3]]}}(SEL.geometricBounds)[DM]}(app.activeDocument.selection[0] , 'L' );

Translate
Ten A
Community Expert
Ten ACommunity ExpertAuthor
Community Expert
Feb 25, 2022 6:05 AM UTC

試しているときに気づいたのですけど、ペーストボード関係なしにどんどん左にずらしていくとオブジェクトのエッジにペーストボードの端が追随して広がっていきますね。こんな挙動でしたっけ???

実に興味深い。

Translate
Participant
Feb 25, 2022 6:13 AM UTC

意外な使い道がありそうですねw

Translate