# Python scripting marching cubes

Hi everyone,

I am looking for someone who can translate this code into python for me: http://www.pasteall.org/66483/javascript

It’s written in Javascript and is called “Naive surface nets”. It takes an array of floats and turns it into a mesh (for three.js/webgl). I’d like to have a basic function that does exactly this so I can play with it in Blender.

I am looking to use the code to generate 3d printable objects like my Entoforms project.

Payment to be determined.

First pass - http://www.pasteall.org/66487/python
Likely to be bugs, but I haven’t got any input data, and I don’t have the time to write a visualiser & sphere generator.

hi, here’s some more" https://github.com/mutantbob/blender-marching-cubes

agoose,

Thanks man… i’ll look at it, and see about providing something as a starting point.

meta: hey that’s great, but maybe I need to redo the title… I am specificly looking for “naive surface nets” not just marching cubes.

agoose77:

In the javascript version I have running the surfacenets function takes two things. An array with dimensions… like:
dims = Array[22,22,22]
And second an array/list of floats with a value between 0 and 1… this list is has a value for every possible position within the dimensions of 22,22,22 (so… 22 * 22 * 22 = 10648 values).

So a simple example of a minimal shape would be dimensions of 3 * 3 * 3
This would be dims = Array[3,3,3]
And the io array would be io = Array[1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1] (27 values and in this case only the middle one is ‘inside’

Thanks for looking into this. Please consider what your fee is to get this working! Feel free to e-mail me as well.

Finished and tested with Sphere, Torus examples.

https://bpaste.net/show/06526b48b25c