edit: Since posting this, I have created a tutorial with a slightly tweaked version of the script shown below. Feel free to check it out for a full explanation of this method, or else just check out the script at the foot of this post.
A while ago I created a simple voxel definition in grasshopper, which worked fine for some geometries, but I thought it was about time that I updated that definition to handle more situations and allow more control.
Firstly, the script currently has been setup to work with a surface/brep geometry as the input. If you would like to voxelise an existing mesh, you will simply need to change the BREP Closest Point component to a Mesh Closest Point component.
This script works a little differently to the previous one. I’ve included the option to create the voxels based on a resolution factor, or on the voxel size factor, and one can switch between these methods using the True/False. If using the voxel resolution factor, then beware of the scale of your scene, a resolution factor of 1 will produce 1 voxel every 1 unit, which could crash your work if you are not careful.
Thirdly, I’ve created an extra function of the script which will create closed water-tight voxel meshes for 3D Printing, if you would like to have that option. In order to use this part of the script you will need to have the weaverbird and [uto] plugins for grasshopper installed on your machine. If you do not have these installed, grasshopper will throw an error upon opening the file. If you don’t need this step, disregard the error. Furthermore, the part of the script which creates the 3D Printable mesh is a rather resource intensive operation, which is why I have included the data dam component to control the flow of your script so that once you are happy with the voxelised output you can ‘press play’ to complete this final bit.
You can download the script here or view it below:
Feel free to ask any questions.