Skip to content

Instantly share code, notes, and snippets.

@shspage
Last active December 18, 2020 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shspage/51e35ae87bd76cfc413268466f991ab5 to your computer and use it in GitHub Desktop.
Save shspage/51e35ae87bd76cfc413268466f991ab5 to your computer and use it in GitHub Desktop.
グリッド上の選択点を元に曲面を補完するテスト
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 = []
values = []
for v in [v for v in vs if v.select]:
points.append(v.co.xy)
values.append(v.co.z)
xi = np.array([v.co.xy for v in vs])
zi = griddata(np.array(points), np.array(values),
xi, method='cubic')
for v,z in zip(vs, zi):
v.co.z = z
func()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment