1
$\begingroup$

I am trying to use the scipy.interpolate.interpn function within blender. I assumed the only way to do this is to utilize the sverchok addon, so my first attempt at using this function is with the sverchok addon, but let me know if there is a better way to do this.

Although I have some basic knowledge of python, I think I am a bit out of my depth here. Nonetheless, I tried writing a script to use with the Scripted Node Lite node in sverchok:

"""
in in_points v
in values s
in xi v
out out_values s
"""

import numpy as np
import sys

from sverchok.utils.logging import exception, info
from sverchok.data_structure import zip_long_repeat

try:
    import scipy
    from scipy.interpolate import interpn
except ImportError as e:
    info("SciPy module is not available. Please refer to https://github.com/nortikin/sverchok/wiki/Non-standard-Python-modules-installation for how to install it.")
    raise e

out_values = []

for everypoint in xi:
    new_values = interpn(points, values, xi, method='linear', bounds_error=True, fill_value=0)
   
    out_values.append(new_values)

Here is what I get when I try to use the script as a scripted node in blender:

enter image description here

error screenshot

here are the files I am working with: https://drive.google.com/file/d/1a2a0l3rghzAbP91JEAb-mZXQZYpiLEsG/view?usp=sharing

If anyone could help me utilize this function in blender, or have any improvements for the script above, I would greatly appreciate it! Thanks,

$\endgroup$
1
  • $\begingroup$ NameError: name 'points' is not defined. You can use simply Blender text editor for creating and executing your script. I don't see why it should be done in Sverchok. $\endgroup$ Commented Mar 30, 2021 at 4:32

1 Answer 1

1
$\begingroup$

Here is an example of simple Sverchok usage, allowing you to interpolate between the two csv files.

enter image description here

use the value slider on the LERP node to Linearly Interpolate between the lists of coordinates. Feel free to ask questions about this, but I don't think this requires SNLite unless you really want to use code.

If you really want to use code you need to explain what you want to achieve with the two csv files, how they are to be interpolated. You have a nice simple example which you should be able to experiment with outside of Sverchok, from the Blender Text Editor.

set up your points, point and values as numpy arrays, and ignore SNLite until you can make it work purely from the TextEditor evaluation/execution. Once you know what python to write, converting the script to something that can be loaded into SNLite is trivial.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .