Skip to content

Instantly share code, notes, and snippets.

@kingtosh
Forked from anonymous/G331_unitSwitch.jsx
Created June 6, 2024 16:03
Show Gist options
  • Save kingtosh/40f98ed5b7ac24e05a001266b3435ba5 to your computer and use it in GitHub Desktop.
Save kingtosh/40f98ed5b7ac24e05a001266b3435ba5 to your computer and use it in GitHub Desktop.
// G331_unitSwitch.jsx
// ミリ単位とピクセル単位をすぐに切り替えるスクリプトです
// http://gorolib.blog.jp/archives/70501774.html
// 0:inch, 1:mm, 2:pt, 3:pica, 4:cm, 5:Q/H, 6:px
PRE = app.preferences
ptEQ = 25.4/72
CKL = 0.1/ptEQ // mmのときのキー入力値です
if(PRE.getIntegerPreference('rulerType')==6){
// 単位がpxだったらmmへ
PRE.setIntegerPreference('rulerType', 1) // mm
PRE.setIntegerPreference('strokeUnits', 1) // mm
PRE.setIntegerPreference('text/units', 2) // pt
PRE.setIntegerPreference('text/asianunits', 2) // pt
PRE.setRealPreference("cursorKeyLength", CKL) // キー入力値は0.1mm
alert('単位をmmに変更しました')
} else {
// 単位がpx以外だったらpxへ
PRE.setIntegerPreference('rulerType', 6) // px
PRE.setIntegerPreference('strokeUnits', 6) // px
PRE.setIntegerPreference('text/units', 6) // px
PRE.setIntegerPreference('text/asianunits', 6) // px
PRE.setRealPreference("cursorKeyLength", 0.5) // キー入力値は0.5px
alert('単位をpxに変更しました')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment