# stl-Voxelisation and coordinates

I am new to Blender and have searched a lot for my problem, but unfortunately have not found anything useful... Is there a possibility to voxelise an stl-file with Blender and to define the voxel size (edge length) in millimeters? My attempt so far was via "Add Modifier" --> "Remesh" and then "Blocks" (Voxels does something else)...But there I can only set the threshold, Octree Depth (whatever that is) and the scale. But I want to set exact millimetres...Is that possible? Furthermore, I would like to write the coordinates of the centers of the voxels into a text file. Is this possible in Blender and if so how? I tried to export the voxelised model (obj, stl, py) and process it with Python to get the coordinates...Unfortunately this failed so far...

Summary: Is there a way to voxelise an stl file with adjustable voxel size (unit of measurement) with Blender and to get the coordinates of the centre points after voxelisation?

Try to play with the Scale facter and Octree Depth in the remesh modifier and use the measure tool on the left toolbar to get your measurements right

as far as i know the remesh modifier is the only way to get what you are looking for.

Voxels are a bit different in blender than what most people think of them as. They aren't cubes like Minecraft - they are a method which uses something like 3d pixels for smoothing shapes or for recreating shapes.

If as u asked in the comments you want to automate this, and you found the Remesh Values that work for you, write them down somewhere and we can write a script to automate this for you

first let's go into the scripting workspace -

Now That you clicked on it you will see on the bottom right the info workspace -

Now before we start scripting, add a simple shape like a sphere

You will see something like this pop up in the info editor

remember what that looks like

now add the remesh modifier to the sphere and set the values to what you wrote down

at this point when you are done you will see something like this

remember what i showed you before? that add sphere? so after it you see i went to the modifier workspace because it says bpy.context.space_data.context = 'MODIFIER' so Now were looking for where i added the remesh modifier because that is what we are going to automate. right after the bpy.context.space_data.context = 'MODIFIER' we see bpy.ops.object.modifier_add(type='REMESH') which adds the remesh modifier (if you read the command u will see it's just english)

So Select it by clicking it and then hold shift and select whatever other commands we want to automate - in this case just the values.

Now with your mouse still over the info editor press ctrl+C

now on the upper right you will see new script button - press it

blender uses python for it's scripting, which makes it pretty simple for simple programs. so first let's give the script access to all the blender commands by typing at the top of the script we just started

import bpy


it's very important to not capitalize anything that isn't supposed to be capitalized.

Now that our script has access to the commands we just need to paste our commands we copied earlier By Pressing Ctrl+V (in order to paste to the right place your mouse has to be hovering over the script editor)

now you can delete the sphere and save the blender file so that the script saves with it.

all we have to do now is import the stl files 1 by 1 and run the script by pressing the little triangle with our object selected and were done!

Notes:

• If you want it to apply the modifier, just do that to the sphere and copy the new command that shows up in the info editor (read it to make sure it has to do with applying modifiers might look something like this - bpy.ops.object.modifier_apply(modifier="Remesh", report=True) )
• you can also make it do anything else like scale the model or something like that - once again just do it to the sphere and then copy the command
• doesn't have to be a sphere, can be anything as long as it's mesh and not a curve or something like that. but a sphere is simple
• unless you know how to program in python probably don't make it export the file or import it in the script because you might accedentally make it do the same thing every time if you don't use loops and correct naming, which would be worthless
• That is definitely a method that works. Thank you! Is there a possibility to "automate" this for different stl-files? Does this mean that I can't get the coordinate points of the supposed cubes (which are not cubes)? May 6 at 8:22
• @llllllllll u can automate this with a script, i will extend the answer to include that May 7 at 9:09
• Thank you very much! It worked out. You helped me alot. It was a perfect explanation! Now i can do the next steps. May 10 at 9:55