Skip to content

Instantly share code, notes, and snippets.

@moluapple
moluapple / find visual center.jsx
Last active September 17, 2023 06:16
[Illustrator] 寻找不规则形状中心点(find visual center of an irregularly shaped polygon with Illustrator)
(function() {
var doc = app.activeDocument,
lays = doc.layers,
WORK_LAY = lays.add(),
NUM_LAY = lays.add(),
i = lays.length - 1,
lay;
// main working loop
for (; i > 1; i--) {
@moluapple
moluapple / word_py3.py
Created March 22, 2012 08:19
[Indesign] Word DLL 简繁转换 python 脚本打包测试
'''
抽出WORD中繁简转换的DLL,直接调用.
需要的文件: MSTR2TSC.DLL MSTR2TSC.LEX MSO.DLL
原文见:http://hyry.dip.jp:8000/code.py?id=105
'''
import ctypes
import win32com.client
@moluapple
moluapple / timeToSave.jsx
Created June 22, 2011 03:35
Popup Image Notifier
/***************************
* 作为bridge启动脚本使用
* 每15分钟弹出图片提示保存文件
* 点击图片使弹窗关闭
* 测试环境: AI CS5 Win7
* ImageURL: http://cdn1.iconfinder.com/data/icons/pry_hardware/512/Time_Machine.png
***************************/
#target bridge
var time = 15; //时间设定,分钟
@moluapple
moluapple / gist:1200180
Created September 7, 2011 09:50
[Illustrator, Scriptographer] Remove Unnecessary PathPoints
// This is a Scriptographer script
document.getItems({
type: Path,
hidden: false
}).each(function (path){
var curves = path.curves, i = curves.length - 1, curve, curvePre;
for (; i > 0; i--){
curve = curves[i];
curvePre = curve.previous;
curve.isLinear() && curvePre.isLinear() &&
@moluapple
moluapple / Menu_Action_JS.jsx
Last active May 16, 2020 17:29
[Illustrator]Create, load and execute action all by JS only
// CS6 only
var set = 'Script Action', // 动作集名称
action = 'PastePDF', // 动作名称
menuEn = 'paste', // 菜单英文
menuZh = '粘贴', // 菜单中文
actionStr = ['/version 3',
'/name [ ' + set.length,
ascii2Hex(set),
']',
@moluapple
moluapple / AI_PGF_Extractor.py
Created March 17, 2012 14:06
Extract PGF data form .ai document (AI 文档净化器)
'''
注:此脚本为 python3 版
'''
import re
def selectFile():
'''利用win32ui选择文件对话框
如果未安装此模块则弹窗输入路径'''
@moluapple
moluapple / gist:2719021
Created May 17, 2012 13:44
AI CS6 Application.executeMenuCommand(menuCommandString: string ) 方法参数列表
menuCommandString,UI MenuString zh_CN
-------------------------------------
new,新建
newFromTemplate,从模板新建
open,打开
saveacopy,存储副本
Adobe AI Save For Web,存储为 Web 所用格式(W)
Adobe AI Save Selected Slices,存储选中的切片
revert,恢复
AI Place,置入(L)
@moluapple
moluapple / A realworld example.jsx
Created August 11, 2012 06:42
[Illustrator] Relaunch AI to aviod "PARM" error
// Origin discussion: http://forums.adobe.com/message/4613051
#target "estoolkit"
rasterizeFolder();
/********************************************************************************************/
function rasterizeFolder() {
//Get the source and destination folders.
//If either window is cancelled, end the script.
@moluapple
moluapple / GBKDecode.jsx
Last active September 18, 2017 14:01
GBK 乱码 fix
function GBKDecode(str) {
var f = File('gbk.txt'), gbk;
f.encoding = 'BINARY';
f.open('w'), f.write(str), f.close();
f.encoding = 'GBK';
f.open('r');
gbk = f.read();
f.close(), f.remove();
return gbk
}
@moluapple
moluapple / Pinyin4ID ContextMenu.jsx
Created April 17, 2012 03:25
[Indesign] Pinyin4ID ContextMenu
#targetengine 'pyModify'
var ruby = {
"阿": ["ā", "ē"],
"挨": ["āi", "ái"],
"艾": ["ài", "yì"],
"熬": ["áo", "āo"],
"拗": ["ǎo", "ào", "niù"],
"扒": ["bā", "pá"],
"把": ["bǎ", "bà"],