Generate Low-Poly Boxing Ring With Blender Python API For Website

Build a Boxing Ring with Blender Python
Build a Boxing Ring with Blender Python

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:

  1. Save the script to a file, e.g., boxing_ring.py.
  2. Open your terminal or command prompt.
  3. 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

Low poly glass bottle Python code
Blender Scripting Workspace Displaying Low Poly Boxing Ring Python Code

Low poly glass bottle in Blender
Blender Layout Workspace Displaying Low Poly Boxing Ring

Low poly glass bottle in Web browser
Web Browser Displaying Rendered Low Poly Boxing Ring

Screencast For Blender Python API Low Poly Boxing Ring

Additional Resources

For those wanting to deepen their knowledge, check out my books:

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!

Recommended Resources:

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.

About Edward

Edward is a software engineer, web developer, and author dedicated to helping people achieve their personal and professional goals through actionable advice and real-world tools.

As the author of impactful books including Learning JavaScript, Learning Python, Learning PHP, Mastering Blender Python API, and fiction The Algorithmic Serpent, Edward writes with a focus on personal growth, entrepreneurship, and practical success strategies. His work is designed to guide, motivate, and empower.

In addition to writing, Edward offers professional "full-stack development," "database design," "1-on-1 tutoring," "consulting sessions,", tailored to help you take the next step. Whether you are launching a business, developing a brand, or leveling up your mindset, Edward will be there to support you.

Edward also offers online courses designed to deepen your learning and accelerate your progress. Explore the programming on languages like JavaScript, Python and PHP to find the perfect fit for your journey.

📚 Explore His Books – Visit the Book Shop to grab your copies today.
💼 Need Support? – Learn more about Services and the ways to benefit from his expertise.
🎓 Ready to Learn? – Check out his Online Courses to turn your ideas into results.

Leave a Reply

Your email address will not be published. Required fields are marked *