選択した基準の外側へ、指定した間隔で線を作るJSXの例です。まず標準のトリムマーク、効果、PDF書き出し時のトンボで要件を満たせるか確認し、独自寸法が必要な場合だけコードを検討します。
標準機能でできること
Adobe公式では、編集できるトリムマークの作成、ライブ効果としてのトリムマーク、日本式への切り替えを説明しています。PDF書き出し時のトンボは、ドキュメント上に作るパスとは別の設定です。トンボの作成・効果・PDF設定の違いを先に確認してください。
以前の掲載コードからの修正
以前の日本式例は左右の中央線2本だけで、入力したオフセットを描画へ反映していませんでした。西洋式例も上の縦線2本だけで、線を作る関数が同じ掲載コード内にありませんでした。いずれも完成したトンボを作る例として使える内容ではなかったため、2026年10月3日に差し替えました。入力文字列をevalで実行する処理も廃止しています。
2026年10月16日には、10月3日に差し替えたコードの作成先レイヤーの判定を直しました。
10月3日から16日まで掲載していた版は、ロックも非表示もしていないレイヤーでも「エラー: 作成先レイヤーが編集できません。」と表示して止まり、線を作れませんでした。
四隅に8本の線を作る学習用の例
下のコードは、選択した1つの基準のgeometricBoundsを使い、四隅の延長線上へ8本の線を作ります。日本式の二重トンボやセンタートンボ、面付け、PDFの仕上がりサイズ・塗り足し設定を生成するものではありません。印刷用の完成仕様として扱わず、座標と単位の計算を学ぶ例として使います。
| 設定 | この例の値・条件 |
|---|---|
| 入力 | 0〜100mmの数値。キャンセルで終了。計算式や文字列は実行しません。 |
| 寸法 | 線の長さ5mm、線幅0.3pt。間隔は基準の辺から線の中心線の端点まで。 |
| 基準 | geometricBounds。線幅や効果を含む見かけの境界とは異なります。長方形1つで試します。 |
| 線色 | CMYKのK100、オーバープリントfalse。レジストレーション色ではありません。入稿先指定とは照合が必要です。 |
| 作成先 | アクティブなレイヤー内の新しいグループ。元オブジェクトは変更せず、自動保存しません。 |
下のコードは、2026年10月16日に作成先レイヤーの判定を直した版です。
以前の版は、Windows 11 Pro(10.0.26200)のAdobe Illustrator 30.8.2で「ファイル」→「スクリプト」→「その他のスクリプト」から実行すると、間隔を入力する画面が出る前に「エラー: 作成先レイヤーが編集できません。」と表示されて止まりました。
作成先のレイヤーはロックも非表示もしていませんでしたが、レイヤーのeditableが値を返さず(undefined)、コード内の!node.editableの条件が成り立っていたためです。
直した版は、この条件を外し、ロック(locked)と表示(visible)だけで作成先のレイヤーを判定します。
(function () {
var group = null;
try {
if (app.documents.length === 0) throw new Error("ドキュメントを開いてください。");
var doc = app.activeDocument;
var sel = doc.selection;
if (!sel || !(sel instanceof Array) || sel.length !== 1)
throw new Error("基準にする長方形を1つ選んでください。");
var bounds = sel[0].geometricBounds;
if (!bounds || bounds.length !== 4) throw new Error("範囲を取得できない選択です。");
var layer = doc.activeLayer;
var node = layer;
while (node && node.typename === "Layer") {
if (node.locked || !node.visible) throw new Error("作成先レイヤーが編集できません。");
node = node.parent;
}
var raw = prompt("基準の辺から線の開始位置までの間隔(mm)", "3");
if (raw === null) return;
raw = raw.replace(/^\s+|\s+$/g, "");
if (!/^(\d+)(\.\d+)?$/.test(raw)) throw new Error("0以上の数値だけを入力してください。");
var mm = Number(raw);
if (!isFinite(mm) || mm > 100) throw new Error("間隔は0〜100mmで指定してください。");
var gap = mm * 72 / 25.4, length = 5 * 72 / 25.4;
var left=bounds[0], top=bounds[1], right=bounds[2], bottom=bounds[3];
if (!(right>left && top>bottom)) throw new Error("基準の幅・高さが0です。");
group=layer.groupItems.add();group.name="Crop marks demo";
var black=new CMYKColor();black.cyan=0;black.magenta=0;black.yellow=0;black.black=100;
line(left-gap-length,top,left-gap,top);line(left-gap-length,bottom,left-gap,bottom);
line(right+gap,top,right+gap+length,top);line(right+gap,bottom,right+gap+length,bottom);
line(left,top+gap,left,top+gap+length);line(right,top+gap,right,top+gap+length);
line(left,bottom-gap-length,left,bottom-gap);line(right,bottom-gap-length,right,bottom-gap);
alert("四隅の線8本を作成しました。寸法・線色・PDFでの範囲を確認してください。");
function line(x1,y1,x2,y2){
var item=group.pathItems.add();item.setEntirePath([[x1,y1],[x2,y2]]);
item.filled=false;item.stroked=true;item.strokeWidth=0.3;item.strokeColor=black;
item.strokeOverprint=false;
}
}catch(e){
if(group!==null){try{group.remove();}catch(cleanup){alert("生成途中のグループが残りました。手動で確認してください。");}}
alert(String(e));
}
}());直したのは、作成先のレイヤーを確かめる次の1行だけです。
// 変更前(ロックも非表示もしていないレイヤーでも止まっていた)
if (node.locked || !node.visible || !node.editable) throw new Error("作成先レイヤーが編集できません。");
// 変更後
if (node.locked || !node.visible) throw new Error("作成先レイヤーが編集できません。");以前の版を保存している場合は、この1行を書き換えてください。
寸法を確認する手順
- コピーしたAIを開き、仕上がりの基準にする長方形を1つだけ選ぶ。
- JSXをUTF-8で保存し、その他のスクリプトから実行する。実行方法はJSX入門を参照。
- 3を入力し、8本の線がグループへ生成されるか確認する。3mmは約8.504pt、5mmは約14.173ptです。
- 生成した線を選び、座標、5mmの長さ、0.3ptの幅、色を照合する。間隔を0・3・10mmに変えて比較する。
- PDFへ出す場合は線が出力範囲に入るか確認する。トンボがあっても塗り足しやPDFのページボックスが整うとは限りません。
2026年10月16日に、直した版をAdobe Illustrator 30.8.2で実行し、0・3・10mmの線の座標と寸法を確かめました(下の結果)。
印刷会社への適合は確かめていません。
独自トンボを入稿する場合は、線色・線幅・長さ・間隔・日本式かどうかを入稿先へ確認して仕様を合わせます。
直した版で確かめた結果(2026年10月16日)
Windows 11 Pro(10.0.26200)のAdobe Illustrator 30.8.2で、直した版を「ファイル」→「スクリプト」→「その他のスクリプト」から実行しました。
入力は400×320ptの自作CMYKドキュメントで、青い長方形(geometricBoundsは左140・上230・右260・下150pt)を1つ置きました。
長方形を選んで実行すると、間隔を入力する画面が既定値3で表示されました。

そのままOKを押すと「四隅の線8本を作成しました。寸法・線色・PDFでの範囲を確認してください。」と表示され、グループ「Crop marks demo」に線が8本作られました。

同じ手順で0と10を入力した結果も含め、左上の2本の端点は次のとおりでした(単位はpt)。
| 間隔 | 左上の横線(y=230)のx | 左上の縦線(x=140)のy | 線の本数 |
|---|---|---|---|
| 0mm | 125.83〜140.00 | 230.00〜244.17 | 8本 |
| 3mm | 117.32〜131.50 | 238.50〜252.68 | 8本 |
| 10mm | 97.48〜111.65 | 258.35〜272.52 | 8本 |
3つの間隔とも、8本すべての端点が計算値と一致しました(差は0.000001pt未満)。
線の長さはすべて5mm(約14.173pt)、線幅は0.3pt、線の色はK100、オーバープリントはオフ、塗りはなしでした。
元の長方形の位置と塗り、線なしの設定は変わっていませんでした。


入力が正しくないときや、長方形を選んでいないときは、次のように止まり、線は作られませんでした。
| 入力・状態 | 表示 |
|---|---|
間隔にabcと入力 | 「エラー: 0以上の数値だけを入力してください。」 |
間隔に101と入力 | 「エラー: 間隔は0〜100mmで指定してください。」 |
| 何も選ばずに実行 | 「エラー: 基準にする長方形を1つ選んでください。」 |
| 入力の画面でキャンセル(キャンセルを押した後、Escキーで閉じた) | 画面が閉じ、線は追加されなかった |
作成先のレイヤーの判定も確かめました。
長方形を選んだまま、レイヤーパネルで作成先のレイヤーの名前をクリックしてから実行しています。
| 作成先のレイヤー | 結果 |
|---|---|
| ロックしたレイヤー | 「エラー: 作成先レイヤーが編集できません。」と表示され、線は0本 |
| 非表示にしたレイヤー | 「エラー: 作成先レイヤーが編集できません。」と表示され、線は0本 |
| ロックした親レイヤーの中のサブレイヤー(サブレイヤー自体はロックも非表示もしていない) | 「エラー: 作成先レイヤーが編集できません。」と表示され、線は0本 |


ドキュメントと親子のレイヤーの用意、線の座標と設定の読み取り、結果の保存はIllustratorのスクリプト機能で行いました。
画面で操作したのは、長方形の選択、直した版の実行、間隔の入力、レイヤーのロック・非表示とレイヤー名のクリックです。
確かめていないのは、RGBのドキュメント、ほかのバージョンとmacOS、PDFの仕上がりサイズや塗り足し、印刷・入稿での適合です。
参照資料
Adobe公式のトリムマークの指定とプリンターマークと裁ち落としを参照しました。過去のGitHub版と旧画像は今回の学習用コードの出力例として扱いません。
よくある質問:トンボを作るJSX
このJSXは、何を作るものですか?
選択した基準の外側へ、指定した間隔で線を作るJSXの例です。選択した1つの基準のgeometricBoundsを使い、四隅の延長線上へ8本の線を作ります。日本式の二重トンボやセンタートンボ、面付け、PDFの仕上がりサイズ・塗り足し設定を生成するものではなく、印刷用の完成仕様として扱わず、座標と単位の計算を学ぶ例として使います。
まず、標準機能で足りないか確認したほうがよいですか?
はい。まず標準のトリムマーク、効果、PDF書き出し時のトンボで要件を満たせるか確認し、独自寸法が必要な場合だけコードを検討するとしています。Adobe公式では、編集できるトリムマークの作成、ライブ効果としてのトリムマーク、日本式への切り替えが説明されています。PDF書き出し時のトンボは、ドキュメント上に作るパスとは別の設定なので、トンボの作成・効果・PDF設定の違いを先に確認してください。
以前の掲載コードは、何が問題だったのですか?
以前の日本式例は左右の中央線2本だけで、入力したオフセットを描画へ反映していませんでした。西洋式例も上の縦線2本だけで、線を作る関数が同じ掲載コード内にありませんでした。いずれも完成したトンボを作る例として使える内容ではなかったため、2026年10月3日に差し替えました。入力文字列をevalで実行する処理も廃止しています。
10月3日から16日まで掲載していた版には、ロックも非表示もしていないレイヤーでも「エラー: 作成先レイヤーが編集できません。」と表示して止まる不具合があり、2026年10月16日に作成先レイヤーの判定の1行を直しました。
コードの設定値や条件を教えてください。
入力は0〜100mmの数値で、キャンセルで終了します。計算式や文字列は実行しません。寸法は線の長さ5mm、線幅0.3ptで、間隔は基準の辺から線の中心線の端点までです。基準はgeometricBoundsで、線幅や効果を含む見かけの境界とは異なり、長方形1つで試します。線色はCMYKのK100でオーバープリントはfalseです(レジストレーション色ではありません)。作成先はアクティブなレイヤー内の新しいグループで、元オブジェクトは変更せず、自動保存しません。入稿先の指定とは照合が必要です。
寸法は、どうやって確認しますか?
コピーしたAIを開き、仕上がりの基準にする長方形を1つだけ選びます。JSXをUTF-8で保存して、「その他のスクリプト」から実行し、実行後に線の本数、座標、5mmの長さ、0.3ptの幅、色を照合します。間隔を0・3・10mmに変えて比較します。
2026年10月16日にAdobe Illustrator 30.8.2で直した版を実行したときは、0・3・10mmのどれも線は8本で、端点は計算値と一致し、長さ5mm・線幅0.3pt・K100でした。
トンボを作れば、PDFの塗り足しも整いますか?
整うとは限りません。PDFへ出す場合は、線が出力範囲に入るか確認してください。トンボがあっても、塗り足しやPDFのページボックスが整うとは限りません。
作ったトンボを、そのまま入稿に使えますか?
独自トンボを入稿する場合は、線色・線幅・長さ・間隔・日本式かどうかを入稿先へ確認して、仕様を合わせます。
2026年10月16日に、直した版をAdobe Illustrator 30.8.2で実行して線の座標と寸法は確かめましたが、印刷会社への適合は確かめていません。
旧GitHub版や、以前の画像は使えますか? 最新はどこで確認しますか?
過去のGitHub版と旧画像は、今回の学習用コードの出力例として扱いません。参照資料は、Adobe公式のトリムマークの指定と、プリンターマークと裁ち落としです。仕様は変わることがあるため、最新はAdobe公式のヘルプで確認してください。

コメント
コメント一覧 (64件)
I liked as much as you will receive carried out right here. The sketch is tasteful, your authored subject matter stylish. however, you command get bought an nervousness over that you would like be delivering the following. in poor health without a doubt come more earlier once more since precisely the same nearly a lot regularly inside of case you shield this increase.
Currently it appears like Drupal is the preferred blogging platform available right now. (from what I’ve read) Is that what you are using on your blog?
Perfectly written content, thankyou for information .
This really answered my drawback, thank you!
Your style is so unique compared to many other people. Thank you for publishing when you have the opportunity,Guess I will just make this bookmarked.
순천출장마사지 타임케어 – 순천출장홈타이와 순천출장안마 순천홈타이 서비스를 전국 어디서나 24시간 편하게! 전문 마사지사의 맞춤 홈케어로 피로를 빠르게 해소
강릉출장안마로 장거리 출장이나 여행의 피로를 풀어보세요. 강릉 전 지역 어디든 찾아가는 전문 아로마 마사지·스포츠 마사지 서비스를 제공합니다. 비즈니스 출장객, 관광객, 강릉 지역 주민 모두 편리하게 이용할 수 있는 강릉출장안마 서비스입니다. 지금 문의하세요.
Please let me know if you’re looking for a article writer for your site. You have some really great posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d really like to write some material for your blog in exchange for a link back to mine. Please blast me an e-mail if interested. Cheers!
포항출장마사지 전문 업체입니다. 24시간 연중무휴 운영과 100 후불제 시스템으로 언제든 편하게 예약 가능! 전원 한국여성 테라피스트가 커플마사지까지 전문 제공
I just like the valuable information you provide on your articles. I will bookmark your blog and test again right here regularly. I am somewhat sure I will learn a lot of new stuff proper here! Best of luck for the next!
I’ve been absent for a while, but now I remember why I used to love this web site. Thanks, I’ll try and check back more often. How frequently you update your website?
I’ve been absent for some time, but now I remember why I used to love this site. Thanks, I will try and check back more often. How frequently you update your website?
I appreciate, cause I found exactly what I was looking for. You have ended my four day long hunt! God Bless you man. Have a nice day. Bye
Just wanna comment on few general things, The website pattern is perfect, the written content is rattling wonderful. “In business school classrooms they construct wonderful models of a nonworld.” by Peter Drucker.
I used to be suggested this website by way of my cousin. I’m not certain whether this post is written by means of him as nobody else know such unique approximately my difficulty. You are wonderful! Thanks!
I do agree with all the ideas you have presented in your post. They’re very convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a bit from next time? Thanks for the post.
excellent put up, very informative. I ponder why the opposite experts of this sector do not understand this. You must continue your writing. I am confident, you have a great readers’ base already!
Once I initially commented I clicked the -Notify me when new comments are added- checkbox and now each time a remark is added I get 4 emails with the identical comment. Is there any way you’ll be able to take away me from that service? Thanks!
Almost all of the things you mention is astonishingly accurate and it makes me ponder why I hadn’t looked at this in this light previously. This article truly did turn the light on for me as far as this subject goes. Nevertheless there is one particular issue I am not necessarily too comfy with so while I make an effort to reconcile that with the main idea of the position, let me see what the rest of your visitors have to say.Well done.
Thank you for the good writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! By the way, how can we communicate?
I enjoy the efforts you have put in this, regards for all the great blog posts.
Great site you have here but I was curious about if you knew of any user discussion forums that cover the same topics discussed in this article? I’d really love to be a part of community where I can get opinions from other experienced people that share the same interest. If you have any recommendations, please let me know. Thanks!
Only wanna comment on few general things, The website pattern is perfect, the subject matter is rattling good : D.
You can definitely see your enthusiasm within the work you write. The world hopes for even more passionate writers like you who are not afraid to say how they believe. At all times go after your heart. “What power has law where only money rules.” by Gaius Petronius.
Thanks for another informative blog. Where else could I get that type of info written in such an ideal way? I’ve a project that I am just now working on, and I have been on the look out for such information.
Very interesting topic, thanks for posting. “I do not pretend to know where many ignorant men are sure-that is all that agnosticism means.” by Clarence Darrow.
After I initially commented I clicked the -Notify me when new feedback are added- checkbox and now each time a comment is added I get 4 emails with the same comment. Is there any approach you may remove me from that service? Thanks!
Hi there! This is my first visit to your blog! We are a group of volunteers and starting a new project in a community in the same niche. Your blog provided us beneficial information to work on. You have done a outstanding job!
An interesting dialogue is price comment. I think that it’s best to write extra on this matter, it may not be a taboo topic however typically persons are not sufficient to talk on such topics. To the next. Cheers
I think this site contains very fantastic composed content blog posts.
Hi there just wanted to give you a quick heads up and let you know a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different internet browsers and both show the same outcome.
It’s in point of fact a great and useful piece of info. I am satisfied that you simply shared this helpful information with us. Please keep us up to date like this. Thank you for sharing.
Your style is so unique compared to many other people. Thank you for publishing when you have the opportunity,Guess I will just make this bookmarked.
You can definitely see your skills within the work you write. The arena hopes for more passionate writers like you who are not afraid to say how they believe. All the time follow your heart.
I’m not sure where you are getting your information, but great topic. I needs to spend some time learning much more or understanding more. Thanks for excellent info I was looking for this information for my mission.
You have brought up a very good details , thanks for the post.
I simply couldn’t go away your web site before suggesting that I extremely enjoyed the usual info a person supply to your visitors? Is going to be again regularly to check up on new posts
Have you ever thought about creating an e-book or guest authoring on other blogs? I have a blog based on the same ideas you discuss and would love to have you share some stories/information. I know my subscribers would enjoy your work. If you’re even remotely interested, feel free to shoot me an e mail.
Thank you for the good writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! However, how can we communicate?
Good post. I be taught one thing more difficult on totally different blogs everyday. It should always be stimulating to learn content from other writers and observe a bit of something from their store. I’d desire to make use of some with the content on my blog whether you don’t mind. Natually I’ll offer you a hyperlink in your web blog. Thanks for sharing.
It is truly a nice and useful piece of info. I am glad that you simply shared this useful information with us. Please stay us informed like this. Thank you for sharing.
Appreciate it for this rattling post, I am glad I found this web site on yahoo.
서울출장마사지 서울출장안마 셀럽은 고객이 머무는 장소에서 관리를 받을 수 있도록 방문 서비스를 안내합니다. 자택이나 숙소의 위치, 원하는 이용 시간, 코스를 알려주시면 예약 가능
I am not positive where you are getting your info, but good topic. I must spend some time learning much more or figuring out more. Thank you for fantastic info I was searching for this information for my mission.
I am no longer certain the place you’re getting your information, however good topic. I needs to spend some time studying more or understanding more. Thanks for fantastic information I used to be on the lookout for this information for my mission.
It’s a shame you don’t have a donate button! I’d most certainly donate to this brilliant blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this website with my Facebook group. Talk soon!
I’ve been browsing on-line more than three hours as of late, yet I never discovered any attention-grabbing article like yours. It’s lovely value enough for me. In my view, if all webmasters and bloggers made just right content material as you did, the internet will likely be much more useful than ever before.
Thanks for the sensible critique. Me & my neighbor were just preparing to do some research on this. We got a grab a book from our area library but I think I learned more from this post. I am very glad to see such excellent info being shared freely out there.
Thanks for your personal marvelous posting! I certainly enjoyed reading it, you might be a great author.I will remember to bookmark your blog and definitely will come back at some point. I want to encourage continue your great job, have a nice afternoon!
You really make it appear really easy together with your presentation however I to find this matter to be really one thing that I think I might never understand. It sort of feels too complicated and very broad for me. I am having a look forward to your subsequent put up, I will try to get the grasp of it!
But wanna input on few general things, The website design is perfect, the content material is really great. “Good judgment comes from experience, and experience comes from bad judgment.” by Barry LePatner.
I am thankful that I observed this web site, just the right info that I was searching for! .
whoah this blog is fantastic i like reading your posts. Stay up the great paintings! You realize, many people are hunting around for this information, you could aid them greatly.
you have a great blog here! would you like to make some invite posts on my blog?
Appreciate it for helping out, great information. “Whoever obeys the gods, to him they particularly listen.” by Homer.
Yesterday, while I was at work, my sister stole my iphone and tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views. I know this is completely off topic but I had to share it with someone!
I am no longer certain the place you are getting your information, however good topic. I must spend a while learning much more or understanding more. Thanks for great information I was in search of this information for my mission.
I dugg some of you post as I thought they were invaluable extremely helpful
Please let me know if you’re looking for a article writer for your site. You have some really good articles and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Many thanks!
소액결제현금화의 의미와 수수료 계산, 실제 부담액을 확인하세요. 휴대폰 결제 한도와 통신요금 청구, 관련 법령, 취소·환불 및 피해 대응까지 공식 자료를 바탕으로 정리했습니다.
Master the methods binary options profit calculator. Compare market signals, choose analysis tools, and learn the specifics of trading and the risks associated with it.
Планируйте качественный сколько стоит ремонт ванны с учетом планировки и ваших пожеланий. Выберите отделочные материалы, сантехнику и дизайн, чтобы создать удобное, функциональное и современное пространство.
부산여성전용마사지 부산토닥이 드디어 부산 상륙 NO.1 부산 최대 규모 관리사들 항시 대기중 24시 연중무휴
Hi would you mind stating which blog platform you’re working with? I’m going to start my own blog soon but I’m having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something unique. P.S My apologies for being off-topic but I had to ask!