0
$\begingroup$

I use a "voxelizer" website where I can convert 3D model to voxels, and I need to import a blend.py file. I'm pretty sure it means python script.

Anyway, how can I export in this format?

Here's the voxelizer I'm talking about: https://drububu.com/miscellaneous/voxelizer/?out=ble

I've checked a lot of tutorial on python scripting in blender but I still can't find an exact solution to my problem.

Thanks

$\endgroup$
1
  • $\begingroup$ I also searched and it looks like currently, it's impossible. I tried to using "Save as python" on voxelizer site and run downloaded python script in Blender app, but nothing happen. I still looking for a way if its possible to export to Python script in Blender app. Thanks all helping from here. $\endgroup$ Sep 30, 2022 at 4:45

3 Answers 3

1
$\begingroup$

TL;DNR: It is a script. It is meant to be opened in the text editor and run. It is broken. I think you should select the '.obj' version of the file and then import it into blender with the obj importer. You might try their forums to see if there is another way.

How to switch to OBJ


I have downloaded their "torus" blender.py file and examined it.

It is, in fact, a script. It is meant to be run this way:

  • Open the Scripting workspace.
  • In the Text editor window click the File Browser icon (looks like a file folder
  • Navigate the browser to where you downloaded 'blender.py' and open it.
  • Click the right arrow (Run button)

But there's a bug. The script is meant for an earlier version of blender and will fail when it tries to update the scene. In the sample file it is at line 4163:

    bpy.context.scene.update()

If you comment out that line you end up reaching yet another bug.

This goes on for some time and the conversion to make it work with Blender 2.8 or later seems non trivial.

I recommend downloading the obj format file instead; although you could check on their forums to see if they're going to produce a version of the script that works with recent versions of Blender.

$\endgroup$
1
$\begingroup$
import bpy

# Create a new mesh
mesh = bpy.data.meshes.new("Human")

# Create a new object with the mesh
obj = bpy.data.objects.new("Human", mesh)

# Add the object to the scene
bpy.context.scene.objects.link(obj)

# Define the vertices of the mesh
vertices = [
    (0, 0, 0),
    (0, 1, 0),
    (0.5, 1.5, 0),
    (1, 1, 0),
    (1, 0, 0),
]

# Create a new polygon for the mesh
faces = [
    (0, 1, 2),
    (2, 3, 4),
]

# Assign the vertices and polygons to the mesh
mesh.from_pydata(vertices, [], faces)

# Update the mesh
mesh.update()
$\endgroup$
0
$\begingroup$

It is quite unusual to import stuff to Blender via a Python script, but sure, geometry or objects can be easily created by a script in Blender, so it's possible to use .py file to import something. If you trust the source of the script with everything you have on your PC, you can open it in or copy it to Blender's text editor and hit "Run script".

enter image description here

If you want to export something out of Blender, you need to either find an add-on for exporting in the format you want, or use existing export options in the File>export menu. Blender also comes with some import-export add-ons that you can find and enable in in the preferences(Edit>Preferences):

enter image description here

As far as I know, you cannot export anything from Blender in Python script format in any standard way, but the website you linked to seems to support other formats.

$\endgroup$

You must log in to answer this question.

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