Python scripting marching cubes

Hi everyone,

I am looking for someone who can translate this code into python for me:

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.

You can find some more information here:

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

Payment to be determined.

First pass -
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"


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.


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.

Original license still stands. Added small BPY mesh example

Awesome! It works!!!

Ok right… so now let me play with it for a bit… see if I can make it do what I have in mind… I’ll get back to you.

Great… Thanks agoose… it works… I’ve added the code to my personal repo at github:

In the addons folder is a and I added your code to the modules (so it can easily be used by multiple things).

We should take this conversation elsewhere since the job is done… Awesome dude… great job, thanks a bunch.