Live stream set for 2025-10-05 at 14:00:00 Eastern
Ask questions in the live chat about any programming or lifestyle topic.
This livestream will be on YouTube or you can watch below.
Create a Boxing Ring 3D Model with Blender Python API and Display It on Your Website
If you're new to Blender and Python but eager to combine 3D modeling with web technologies, this beginner-friendly tutorial will walk you through generating a simple boxing ring model using Blender's Python API and displaying it directly in a web browser using the <model-viewer> component.
What You'll Learn
- How to write a Python script to create a boxing ring model in Blender.
- How to run the Python script from the command line.
- Exporting your 3D model to a web-friendly format.
- Embedding your 3D boxing ring in a website using <model-viewer>.
Step 1: Creating the Boxing Ring in Blender via Python
Blender provides a powerful Python API that lets you automate modeling tasks. Here's a very simplified example of how you might generate the boxing ring geometry (boxing ring ropes, floor, and posts) with a Python script inside Blender.
import bpy def create_boxing_ring(): # Clear existing objects bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_by_type(type='MESH') bpy.ops.object.delete() # Create the floor bpy.ops.mesh.primitive_plane_add(size=10, enter_editmode=False, align='WORLD', location=(0, 0, 0)) bpy.context.object.name = "RingFloor" bpy.context.object.scale = (1, 1, 0.1) # Make it slightly thick # Create the posts post_locations = [ (4.5, 4.5, 2), (-4.5, 4.5, 2), (4.5, -4.5, 2), (-4.5, -4.5, 2) ] for loc in post_locations: bpy.ops.mesh.primitive_cylinder_add(radius=0.2, depth=4, enter_editmode=False, align='WORLD', location=loc) bpy.context.object.name = "RingPost" # Create the ropes (simplified) # This is a basic representation, more complex ropes would involve curves and path following rope_heights = [1, 1.5, 2] for h in rope_heights: # Front rope bpy.ops.mesh.primitive_cube_add(size=0.1, enter_editmode=False, align='WORLD', location=(0, 4.5, h)) bpy.context.object.scale = (9, 0.1, 0.1) # Back rope bpy.ops.mesh.primitive_cube_add(size=0.1, enter_editmode=False, align='WORLD', location=(0, -4.5, h)) bpy.context.object.scale = (9, 0.1, 0.1) # Left rope bpy.ops.mesh.primitive_cube_add(size=0.1, enter_editmode=False, align='WORLD', location=(-4.5, 0, h)) bpy.context.object.scale = (0.1, 9, 0.1) # Right rope bpy.ops.mesh.primitive_cube_add(size=0.1, enter_editmode=False, align='WORLD', location=(4.5, 0, h)) bpy.context.object.scale = (0.1, 9, 0.1) print("Boxing ring created!") create_boxing_ring()
This script clears the scene and creates a simple boxing ring with a floor, four posts, and three horizontal ropes on each side.
Step 2: Running the Script on the Command Line
To run this Python script in Blender without opening the UI:
- Save the script to a file, e.g.,
boxing_ring.py
. - Open your terminal or command prompt.
- Run Blender in background mode with your script:
blender --background --python boxing_ring.py --save-as boxing_ring.blend
This command runs Blender headlessly, executes your script, and saves the scene as boxing_ring.blend
.
Step 3: Exporting for the Web
You can export your model to glTF/glb format, which is compatible with web viewers like <model-viewer>.
From inside Blender or via Python, export your model:
blender boxing_ring.blend --background --python-expr "import bpy; bpy.ops.export_scene.gltf(filepath='boxing_ring.glb')"
Step 4: Displaying the Model in a Web Browser
Using the lightweight <model-viewer> web component, you can easily embed your 3D boxing ring.
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
<model-viewer src="boxing_ring.glb" alt="3D Boxing Ring" auto-rotate camera-controls style="width: 600px; height: 400px;">
</model-viewer>
Place the boxing_ring.glb
file in your website folder or host it online, and embed this snippet in your HTML page.
📸 Screenshots & Screencast



Additional Resources
For those wanting to deepen their knowledge, check out my books:
- Learning Python – A great start for beginners looking to learn Python programming.
- Mastering Blender Python API – A comprehensive guide to Blender scripting for more advanced projects.
You can also enroll in my Learning Python course for structured learning.
Need Personalized Help?
I offer one-on-one online Python tutorials including Blender scripting to help you build projects like this. Feel free to contact me here for scheduling and details.
If you enjoyed this tutorial or want to see more, let me know in the comments!
Disclosure: Some of the links above are referral (affiliate) links. I may earn a commission if you purchase through them - at no extra cost to you.