なんてこったorz デバッグ初めもやっちまった。 0014名称未設定2014/01/02(木) 12:10:19.86ID:ipDSuQZK0 直前のスペースも全角だから注意w 0015名称未設定2014/01/06(月) 19:04:31.61ID:7CI/xVnp0 今年もよろしくお願いします。 applescriptでillustratorの行間を変更しようと試みていますが 以下たけうちさんのを参考にと思いillustratorライブラリをみていますがなかなか難しいですね。 ちなみにscriptは tell application "Adobe Illustrator" tell document 1 tell text frame 1 tell paragraph 1 set justification to full justify last line left
--right以外にも下記の種類がある --center/full justify/full justify last line center/ --full justify last line left/full justify last line right --/left/right end tell end tell end tell end tell
これって行間の解説をみてみるとleadingというのに当てはまるようですがleadingに leading (real) : the amount of space between two lines of text (in points) とあります (行間をつめたいけどできない)でやりたいのだがどなたかご教授ください。 0016名称未設定2014/01/06(月) 23:03:17.53ID:OUsnDFhy0>>15 tell application "Adobe Illustrator" tell document 1 tell text frame 1 tell paragraph 1 set auto leading to false set leading to 10 --単位はpt end tell end tell end tell end tell
とかになるよ。 数値適用する前に改行の自動をオフにしないとダメ。 paragraphを対象にしていると最終行が改行で終わっているとleadingに数値適用するとエラーとなるので text frame全体に適用するにはevery paragraph(paragraphs)ではなくevery line(lines)で
tell text frame 1 set auto leading of lines to false set leading of lines to 10 end tell
↑tell text frame外省略 0017名称未設定2014/01/06(月) 23:49:20.98ID:7CI/xVnp0>>16 どうもありがとうございました。m(_ _)m set auto leading of lines to false set leading of lines to 10
この辺りのやり方(文法みたいのがどこかにあると思いますが)がどうもわかりません。 leading (real) : the amount of space between two lines of text (in points)
から auto leading こういう風な lines to false とか どう学べばそういう答えがでるのか不思議です。 applescriptは中学英語なみとかいわれているけどライブラリをみる限りチンプンカンプンですね。
set leading of lines to 10 なんか どうひねっても浮かんできませんね。(^^;)
でも行間の操作ができましたのでとても助かりました。本当にありがとうございました。感謝です! 0018名称未設定2014/01/07(火) 00:25:10.25ID:WILu6W1O0>>17 >>16の最後の部分は tell text frame 1 tell lines set auto leading to false set leading to 10 end tell end tell これと同じ。 ちょっと値代入するだけなのにtellでくくるのはめんどくさいので set auto leading of lines to false set leading of lines to 10 とした。 set leading of lines to 10 は優先される部分をあえてカッコでくくると set (leading of lines) to 10 カッコ内の△△ of □□ってのは「□□の△△」って意味なので lines(全ての行)のleading(行間)を10にするってこと。 実は↓これでもOK set lines's leading to 10
auto leading は最初スクリプト組んで実行してみたら行間変わらなかったので、 Illustratorの書類見たら改行が自動のままだった。 それから解説のlinesとかparagraphの項目みたら PROPERTIESにauto leadingって項目があったからfalseにしてみたらうまくいったよ。
set tmp1 to item 2 of item 1 of testItem set tmp2 to item 2 of item 1 of item 1 of testItem
log tmp1 & "_" & tmp2 as text 0020名称未設定2014/01/07(火) 04:19:36.79ID:A9XxL9bQ0 失礼 アンパサンドの文字参照がダメなようで全角で log tmp1 & "_" & tmp2 as text は log tmp1 & "_" & tmp2 as text &を全角にしてます 0021名称未設定2014/01/07(火) 12:17:10.13ID:pSl4+Q4s0 それってtestItemにtest1そのものではなくtest1の値を代入してるだけなんで、 変数名どーこー以前の問題ですわ 0022名称未設定2014/01/07(火) 12:37:03.68ID:EjQxpbCu0>>18 >用語解説の >(real)は実数 >(boolean)はtrueかfalse >他にも色々あるけどそれぞれのプロパティの値は形式が決まっているから代入出来る値もそれに合わせないといけない。 >r/oって書いてあるのはread onlyの略で値を見ることは出来るけどスクリプト側で設定することは出来ないって事だよ。
解説ありがとうございます。m(_ _)m なるほどそういうことですか。
どころで全体の文章で行間を変えるには別な記述でしょうか? 現況の >set auto leading of lines to false >set leading of lines to 10 では 行間変更では改行がある前は行間ポイントが変更できますが それ以降の行間は変更がなされないのは他に書き方があるのでしょうか? >every line(lines) と変更しても改行後の文には行間は及ぼしません。
どころで全体の文章で行間を変えるには別な記述でしょうか? 現況の >set auto leading of lines to false >set leading of lines to 10 では 行間変更では改行がある前は行間ポイントが変更できますが それ以降の行間は変更がなされないのは他に書き方があるのでしょうか? >every line(lines) と変更しても改行後の文には行間は及ぼしません。
最初の行に property i : 24 とりあえずトップに挿入する。行間24ptで固定 .... .... ....display dialog "オーバーフロー:" のところに下記スクリプトを挿入した .... tell application "Adobe Illustrator" tell document 1 tell every text frame tell every line set auto leading of lines to false repeat with i from 20 to i set leading of lines to i end repeat end tell end tell end tell
のような感じに行間をテキストボックス内で自動的に収まるようにしたのだが思うようにいきません。
テキストボックスは固定してテキストが少なくても全体が均一になるよう自動行間、自動調整できないかと思案しています。 どなたかご教授よろしくお願いします。 0028名称未設定2014/01/11(土) 01:25:24.03ID:bFFRZv4H0 repeat with i from 20 to i 普通こんな記述はしない。 行間の初期値は該当するtext frameから読み取った方が良いし 目的のtext frameがtext frame 1で全行同じ行間であれば tell document 1の後に set defLeading to leading of character 1 of text frame 1 1文字目の行間を取得で十分 オーバーフローしてるテキストボックスをの行間を詰めるにしても 行間を少しずつ(例えば0.1ptずつとか)「減らす」記述にしないとダメ。 repeat with i from defLeading to 0 by -0.1 減らす毎に文字がオーバーフローしていないかチェックして 文字が収まったらexit repeatっていう処理が必要 tell every text frame の辺りも全部のテキストフレームに一括で同じ処理する場合のみ使う。
というかあなたにそのスクリプトはちょっと難しすぎる。このまま進むのは危ない。 ハンドラ(サブルーチン・関数)の使い方も分からないでしょ? on overflow(tFrame) … end overflow の部分
たけうちとおるさんのハンドラを利用してオーバーフローしたテキストに行間を計算させて 必要なテキストボックスのオーバーフローの分を自動計算させる事にこぎ着けました。 まだ改善の余地はありますがなんとか思惑通りになりほっとしています。 今のところ別textframeの行間も一緒に動いているようなので指定したtext frameだけの行間を調整できるようにしたいと思います。 アドバイスありがとうございました。引き続きご教授賜りますようお願いいたします。 0034名称未設定2014/01/11(土) 23:13:33.10ID:QDclpEY40 tell application "Adobe Illustrator" tell document 1 -- ← every document にすると全体のテキストにスクリプトが動くのであえてDocument1にしています --set defLeading to leading of character 1 of text frame 1 set defLeading to "20" -- ←本文の行間を固定しています。ここは書類に応じて変更したりします。 repeat with tFrame in every text frame if kind of tFrame is {area text} then if my overflow(tFrame) then --display dialog "オーバーフロー:" & contents of tFrame ←ここでオーバーフローしたテキストが抽出されますのでこれを利用しました。 tell every text frame tell every line repeat with i from defLeading to 0 by -1 ←ここで行間を縮めています set auto leading of lines to false set leading of lines to defLeading end repeat end tell end tell end if end if end repeat end tell end tell 0035名称未設定2014/01/11(土) 23:14:36.55ID:QDclpEY40 ハンドラはたけうちとおるさんのを参照しています on overflow(tFrame) set OriginalDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to "" tell application "Adobe Illustrator" set myLastP to (contents of every paragraph of tFrame) as string set myLastL to (contents of every line of tFrame) as string set AppleScript's text item delimiters to OriginalDelimiters if myLastP is not myLastL then set AppleScript's text item delimiters to OriginalDelimiters return true else set AppleScript's text item delimiters to OriginalDelimiters return false end if end tell end overflow 0036名称未設定2014/01/11(土) 23:27:23.61ID:bFFRZv4H0 とりあえずユーザー定義ハンドラの使い方の例
set theText to "あいうえお" set startCount to 1 set endCount to 2 my textMask(theText, startCount, endCount)
set aaa to "かきくけこ" set bbb to 2 set ccc to 4 my textMask(aaa, bbb, ccc)
my textMask("さしすせそたちつてと", 5, -1)
on textMask(theText, startCount, endCount) set resultText to text startCount thru endCount of theText set startCountText to my minusCheck(startCount) set endCountText to my minusCheck(endCount) display dialog "テキスト「" & theText & "」の" & startCountText & "文字目〜" & endCountText & "文字目までは「" & resultText & "」です" end textMask
on minusCheck(theCount) if theCount < 0 then return "最後から" & (-theCount as Unicode text) else return theCount as Unicode text end if end minusCheck
あー何か勉強し始めた頃を思い出したよ。 最初ハンドラ内の変数名と呼び出し側の変数名が違って大丈夫なの?とか思ってた。 0037名称未設定2014/01/11(土) 23:30:57.28ID:bFFRZv4H0>>34 >if my overflow(tFrame) then の後の >tell every text frame は >tell tFrame で良いよ 0038名称未設定2014/01/11(土) 23:33:03.24ID:QDclpEY40 追伸 tell text frame 1~18ぐらいの範囲でtext frameが指定できるようです。
参考にさせていただきます。 0041名称未設定2014/01/11(土) 23:39:53.28ID:bFFRZv4H0>>34 >set defLeading to "20" set defLeading to 20 にしないと数値として扱えないんじゃないかな?
>repeat with i from defLeading to 0 by -1 ←ここで行間を縮めています >set auto leading of lines to false >set leading of lines to defLeading >end repeat これだと行間0になるまで止まらない気がするよ。(実際は0になったとこでIllustrator側でエラー返すと思うけど)
repeat with i from defLeading to 0 by -1 ←ここで行間を縮めています set auto leading of lines to false set leading of lines to defLeading if not my overflow(tFrame) then exit repeat end if end repeat 0042名称未設定2014/01/11(土) 23:54:58.99ID:QDclpEY40 >41 ありがとうございます。m(_ _)m
------返された値 計算が続いて...... set auto leading of every line of every line of every text frame of document 1 to false set leading of every line of every line of every text frame of document 1 to "22" get kind of item 7 of every text frame of document 1 --> {point text} 計算が続いて...... get kind of item 18 of every text frame of document 1 --> {point text} end tell
>repeat with i from defLeading to 0 by -1 ←ここで行間を縮めています >set auto leading of lines to false >set leading of lines to defLeading >if not my overflow(tFrame) then >exit repeat >end if >end repeat
これだと以下の部分がなくなりました ーーーーーーー返された値 set auto leading of every line of every line of every text frame of document 1 to false set leading of every line of every line of every text frame of document 1 to "22" get kind of item 7 of every text frame of document 1 --> {point text}
------------------返された値 この部分が残りました get kind of item 18 of every text frame of document 1 --> {point text} end tell 0045名称未設定2014/01/12(日) 00:23:03.89ID:yPrbZhDQ0>>44 >>37の部分は修正してる? 18番目のテキストフレームの種類が{point text}(エリアテキストではなく普通に打ち込んだテキスト)って事だけど
あと set auto leading of lines to false は1回実行すれば大丈夫なのでrepeatの外でOKだったのと さらに一つ見逃してた。 repeatでiを変動させて行間変えないと行けないのにdefLeading設定しちゃってる。 >set leading of lines to defLeading は set leading of lines to i で
set auto leading of lines to false repeat with i from defLeading to 0 by -1 ←ここで行間を縮めています set leading of lines to i if not my overflow(tFrame) then exit repeat end if end repeat 0046名称未設定2014/01/12(日) 01:14:51.44ID:yPrbZhDQ0 あー何度もごめん。 set leading of lines to i だとエリアに収まってる部分しか行間変えてくれないから paragraph指定するしかないのか。 set auto leading to falseとか 最後が改行で終わってるとエラーになるからIllustratorの書類側で気を使わないといけないかも。 最初から自動行間になっていない事前提なのと最後が改行で終わっていないというのが条件
tell tFrame tell every paragraph repeat with i from defLeading to 0 by -1 set leading to i if not my overflow(tFrame) then exit repeat end if end repeat end tell end tell 0047名称未設定2014/01/12(日) 01:20:17.06ID:yPrbZhDQ0 あ、やっぱダメだ… エリア外のparagraphに対してleadingの設定ができなさそう。 0048名称未設定2014/01/12(日) 10:47:12.63ID:od5l1ettP ウザすぎ。ここは手取り足取り教える場所じゃねーんだよ。よそでやれ。 0049名称未設定2014/01/12(日) 10:49:19.47ID:od5l1ettP 書き忘れた。やるならここ見てるいろんな人に還元しながらやれ。それなら歓迎。 0050名称未設定2014/01/12(日) 22:23:31.18ID:4upz722c0 >46さん いろいろありがとうございます。m(_ _)m
結局下記のような記述で自動行間を整える事にしました。 ご指摘の >set leading of lines to i に変更して起動したところとりあえずエラーもなくできています。
おっしゃる通りです。皆様とともに学びを通してapplescriptでの可能性を見てみたいと思っています。今後ともよろしくお願いします。 0051名称未設定2014/01/12(日) 22:26:26.36ID:4upz722c0 行間を自動にてつめるスクリプトですが改良の余地がまだたくさんあるようです。 個人的にはこのスクリプトで自分が自分が目指していたのができとても喜んでいます。 下記に教えてくださった皆様のscriptを元に利用しているapplescriptです。 tell application "Adobe Illustrator" tell document 1 -- ← every document にすると全体のテキストにかかるようであえてDocument1にします --set defLeading to leading of character 1 of text frame 1 set defLeading to "24" -- ←本文の行間を固定しています repeat with tFrame in every text frame if kind of tFrame is {area text} then if my overflow(tFrame) then --display dialog "オーバーフロー:" & contents of tFrame tell text frame 6 tell every line repeat with i from defLeading to 0 by -1 set auto leading of lines to false set leading of lines to i if not my overflow(tFrame) then exit repeat end if end repeat end tell end tell end if end if end repeat end tell end tell 0052名称未設定2014/01/12(日) 22:27:20.26ID:4upz722c0 たけうちとおるさんのハンドラをそのまま利用しています。 on overflow(tFrame) set OriginalDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to "" tell application "Adobe Illustrator" set myLastP to (contents of every paragraph of tFrame) as string set myLastL to (contents of every line of tFrame) as string set AppleScript's text item delimiters to OriginalDelimiters if myLastP is not myLastL then set AppleScript's text item delimiters to OriginalDelimiters return true else set AppleScript's text item delimiters to OriginalDelimiters return false end if end tell end overflow 0053名称未設定2014/01/13(月) 03:11:37.98ID:Sx62P48w0 do shell scriptを何度も繰り返しているのだけど、shellコマンドを入力する度に別のターミナルが開いてしまう。
tell application "Terminal" do script with command "hoge" do script with command "hoge2" end tell
hogeとhoge2のコマンドを一つのターミナルウィンドウで処理させる事ってできますか? 0054名称未設定2014/01/13(月) 03:29:47.81ID:XwnsQAAS0 コピペで動くんじゃないか 0055名称未設定2014/01/13(月) 04:10:03.05ID:VPcx8yeO0>>53 --ただ続けて実行したいだけなら tell application "Terminal" do script "hoge; hoge2" end tell
--do scriptの戻りが実行されたtabなのでそれを使うパターン tell application "Terminal" do script "hoge" do script "hoge2" in result end tell
tell application "Adobe Illustrator" tell document 1 tell text frame 1 set properties of every paragraph of text frame 1 in document 1 to {text font:"Osaka"} end tell end tell end tell 0058名称未設定2014/01/14(火) 21:10:07.61ID:ZXykgTnJ0>>57 ここで散々質問してきた人? だとしたら成長の跡が見られない。 tellとはなんぞやからやり直した方が良い。 0059名称未設定2014/01/14(火) 22:03:45.56ID:VipRDOQb0 >58 これでいいの? set setStr to "サンプルテキスト" set X to 10 set Y to 10 set setStr to setStr as string set X to X as real set Y to Y as real set pt to 2.83 set X to X * pt set Y to Y * pt tell application "Adobe Illustrator" set placedRef to make new text frame in document 1 with properties {contents:setStr, position:{X, Y}} set properties of every paragraph of text frame 1 in document 1 to {size:8.5, fill color:{class:CMYK color info, black:100, cyan:0, magenta:0, yellow:0}, text font:"ShinGo-Bold-83pv-RKSJ-H"} end tell 0060名称未設定2014/01/14(火) 22:57:38.60ID:VipRDOQb0 >58 それともこれかな? tell application "Adobe Illustrator" set docRef to make new document with properties {color space:CMYK} set romanText to "日本語書体変換" set newText to romanText set textRef to make new text frame in docRef with properties {position:{100, 200}, contents:newText} set charStyle to make new character style in docRef with properties {name:"ヒラギノ明朝 Pro-W3"} set kerning method of charStyle to metricsromanonly set properties of every paragraph of text frame 1 in document 1 to {size:48} set cmykColor to {cyan:50, magenta:20, yellow:10, black:5} set fill color of charStyle to cmykColor apply character style charStyle to text of textRef end tell 0061名称未設定2014/01/14(火) 23:30:19.11ID:VipRDOQb0 >58 >だとしたら成長の跡が見られない。
人の可能性を育てるのもこの世界だ。なんらかの縁でここに来ているならそれこそ大事にしなさいな。 わからん人には何倍でも説明したら説明するほど自分の理解度が増していく。それはあらゆるところから情報を 得ようと自分が勉強することになるからね。 それが社会勉強なんだよ。プログラムを訪ねにここへ来る人はそれが本来の目的ではないと思う。 最終的に誰かにきちんと説明だできるまでになるようになるための勉強でもあるんだよ。 だから人が困っているなら自分が勉強したのが役立つときなのだ。 58さんわかったかね。 0067名称未設定2014/01/15(水) 11:54:31.85ID:UeMn6f2J0 見えないレス多すぎ 0068名称未設定2014/01/15(水) 12:03:57.04ID:/LtsrHqK0 あたまのわるいやつおおすぎ 0069名称未設定2014/01/15(水) 12:43:41.67ID:/LtsrHqK0 tell application "Adobe Illustrator" set docRef to make new document with properties {color space:CMYK} set romanText to "日本語書体変換" set newText to romanText set textRef to make new text frame in docRef with properties {position:{100, 200}, contents:newText} set charStyle to make new character style in docRef with properties {name:"ヒラギノ明朝 Pro-W3"} set kerning method of charStyle to metricsromanonly set properties of every paragraph of text frame 1 in document 1 to {size:48} set cmykColor to {cyan:50, magenta:20, yellow:10, black:5} set fill color of charStyle to cmykColor apply character style charStyle to text of textRef end tell
書体変換ができないのだが set charStyle to make new character style in docRef with properties {name:"ヒラギノ明朝 Pro-W3"} これってどうだろうか 0070名称未設定2014/01/15(水) 12:56:37.57ID:rX7GSZ3z0 58もしょーもないけどあんたもぶちまけ過ぎ 0071名称未設定2014/01/15(水) 13:32:40.20ID:NM6x1RRT0 だな。てか、やっぱり教えてほしい方が教えてくれる人を定義しているのか? だったらダメダメだなあ。連投で超ダメダメ具合を晒して病んでるなと思うな。黙って質問だけしてりゃいいのに 0072名称未設定2014/01/15(水) 14:38:35.33ID:/LtsrHqK0 >70 >71 >あんたもぶちまけ過ぎ 本音で語らないといけないと教わっているもんでね。 >やっぱり教えてほしい方が教えてくれる人を定義しているのか? 定義も何もしてないし、ごく普通の感覚だよ。 技術者の前に人であってほしいという思いだけです。 >連投で超ダメダメ具合を晒して病んでるなと思うな。 連投ではだめですか? 枯れ木も山のにぎわいというではないかね。 盛り上げたいだけですよ。(笑 >黙って質問だけしてりゃいいのに 何かを恐れながら聞き出しているって感じだね。 牽制しながら質問しているようだが....お互い成長期ですかね。幼少期か。 すごいプログラム例えば自動化をしている人がいますか? 印刷業界で第一人者、デジタルでばりばりapplescriptを利用していますか? それも自動化にして楽してお仕事してますか? applescriptで日本を代表する人がここにいますか? applescriptの執筆活動家はいますか? もしそういう人がここにいたなら日本のapplescriptのベースを引き上げてほしいな。 まぁ諸先輩方の考え方はよく知らないけどこの程度でだめだしならしょうがないね。 もう少し太っ腹かと期待したが無理だったということか。 まあせいぜい牽制しながらぼちぼちやりなよ。(笑 また質問などさせてもらうけどね。 0073名称未設定2014/01/15(水) 14:58:13.51ID:NM6x1RRT0 >本音で語らないといけないと教わっているもんでね 教わっているなら、>>58のもそのままとればいい。自分が語るのだけ?他人が語るのは許さないの? 全くAppleScriptと関係無いのにうんざりだぜ
あんたが教える立場であってもあんたのような態度ではあんたは教えないだろ?それは、あんたの>>58の異常な反応から明らかだと思うのだが まあ、見物だなあ。質問する時も現在の態度でどうかよろしくw 0074名称未設定2014/01/15(水) 15:05:27.12ID:/LtsrHqK0 >73 >まあ、見物だなあ。質問する時も現在の態度でどうかよろしくw よろしくねw まぁせいぜい腕を磨いて貢献してねw どんどん質問するからねw 0075名称未設定2014/01/15(水) 15:07:18.04ID:NM6x1RRT0 本気で言っているの?それ。他人を自分の都合の良い人としか見てないってことだよ? 0076名称未設定2014/01/15(水) 15:14:28.03ID:/LtsrHqK0 >75 冗談さ 0077名称未設定2014/01/15(水) 15:17:00.22ID:NM6x1RRT0 冗談では済まない。済まないので「すみません」という言うべきだなw あんだけ饒舌であーだこーだ言うのだからそのくらいは言うべきだろう 0078名称未設定2014/01/15(水) 15:21:21.85ID:/LtsrHqK0 >77 >冗談では済まない。済まないので「すみません」という言うべきだなw すみませんw 0079名称未設定2014/01/15(水) 15:25:42.76ID:NM6x1RRT0 なぜ、w をつける。言っている事とやっている事が乖離しているぞ まあ、なんかまムカついている、また、変なプライドwだけはすごいというのは既知のことなので、それで許してやろう、俺はw 全くAppleScriptと関係無いのにうんざりだぜなのにいw長くなったがおしまい 0080名称未設定2014/01/15(水) 16:16:23.79ID:/LtsrHqK0 >全くAppleScriptと関係無いのにうんざりだぜなのにいw じゃあさ。 書体変換ができないのだが set charStyle to make new character style in docRef with properties {name:"ヒラギノ明朝 Pro-W3"} これってどうだろうかね知っている? 変換ができないんだよ。 Marvericksでさ、Illustrator CC 使ってんだ。 だが書体変更がきかんのだよそちらならすぐ解けるんでしょ。ちょっと難しいかな? 0081名称未設定2014/01/15(水) 17:01:36.69ID:NM6x1RRT0 その調子でいいよw 「ちょっと難しいかな?」と煽ってる(&できれば答えが欲しい)のだろうが、わからないお前が何を言うー、ってことだけにしかならないに まあ、飽きれたけど考えてみればば調子が変わっていないのでよろしいw