Skip to content

Instantly share code, notes, and snippets.

@shspage
shspage / 1_example_mxi_for_aip.md
Last active February 10, 2024 19:34
Illustrator用プラグインからzxpを作成する例

Illustrator用プラグインからzxpを作成する例

ディレクトリ構造(プラグイン名:anchorGrabber.aip の場合)

  • anchorGrabber
    • anchorGrabber.mxi
    • mac
      • anchorGrabber.aip

zxp生成コマンドはHTML拡張からzxpを作成する場合と同じ

;; grid specification
(def interval 40)
(def nlines 10)
(transform [1 0 0 1
(* nlines interval -0.5)
(* nlines interval -0.5)]
;; circles as controller
(def cs [
;; grid specification
(def interval 40)
(def nlines 10)
(transform [1 0 0 1
(* nlines interval -0.5)
(* nlines interval -0.5)]
;; circles as controller
(def cs [
import bpy
import math
import numpy as np
from time import time
# 参考:
# https://blender.stackexchange.com/questions/190547/mesh-edges-foreach-set-doesnt-update
bpy.app.handlers.frame_change_pre.clear()
bpy.app.handlers.frame_change_post.clear()
@shspage
shspage / blender_smooth_surface_study.py
Last active December 19, 2020 12:01
いびつな面をなめらかにするテスト
import bpy
import numpy as np
from scipy.interpolate import Rbf
def getGridEdgeIndices(polys):
"""Gets the index of the vertices on the outer edge"""
idxs = []
for poly in polys:
idxs.extend([x for x in poly.vertices])
idxs, counts = np.unique(idxs, return_counts=1)
@shspage
shspage / blender_interpolate_study.py
Last active December 18, 2020 14:59
グリッド上の選択点を元に曲面を補完するテスト
import bpy
import numpy as np
from scipy.interpolate import griddata
def func():
bpy.ops.object.mode_set(mode='OBJECT')
grid = bpy.data.objects['Grid']
vs = grid.data.vertices
points = []
import bpy
import numpy as np
from scipy.spatial import ConvexHull
MAX_ITERATION = 10
MAX_ERROR_SQUARED = 1e-4
NUM_POINTS = 400
RADIUS = 10 # 球の半径
points = np.random.randn(3, NUM_POINTS)
@shspage
shspage / sketch_dec-06-2020_20-44-19.glisp.glisp
Last active December 17, 2020 12:32
gilsp( https://github.com/baku89/glisp ) 用スクリプトです。多角形をUIとして使う習作
; controllers
(def G0 (ngon [1 1.8125] 137 11))
(def G1 (ngon [3 0.8125] 106 7))
(def G2 (ngon [9 -4.1875] 74 8))
(def G3 (ngon [8 -1.1875] 46 5))
; coordinates of the nth vertex
(defn fv [s n] (nth s (inc n)))
; number of vertices
(defn fc [s] (dec (count s)))
(def spiral_radius 30)
(def interval 1.2)
(def arc_angle (deg 80))
(defn prepare [tr t r]
(if (> r spiral_radius)
tr
(let [t1 (+ t (atan2 interval r))
r1 (+ r (/ interval t1))]
(prepare (conj tr t1 r1) t1 r1))))