Skip to main content

CubeForge

License: MIT Python Version

CubeForge is a Python library designed to easily generate 3D mesh files (currently STL format) by defining models voxel by voxel. It allows for flexible voxel dimensions and positioning using various anchor points.

Features

  • Voxel-based Modeling: Define 3D shapes by adding individual voxels (cubes).
  • Non-Uniform Voxel Dimensions: Specify custom width, height, and depth for voxels.
  • Flexible Anchoring: Position voxels using different anchor points (cubeforge.CubeAnchor) like corners or centers.
  • STL Export: Save the generated mesh to both ASCII and Binary STL file formats.
  • Simple API: Easy-to-use interface with the core cubeforge.VoxelModel class.

Installation

Install from PyPI: You can install CubeForge directly from PyPI using pip:

pip install cubeforge

Install from source: You can also clone the repository and install the package using pip:

pip install .

Usage

Here's a basic example of how to create a simple shape and save it as an STL file:

import cubeforge
import os

# Create a model with default 1x1x1 voxel dimensions
model = cubeforge.VoxelModel()

# Add some voxels using the default CORNER_NEG anchor
model.add_voxel(0, 0, 0)
model.add_voxel(1, 0, 0)
model.add_voxel(1, 1, 0)

# --- Or add multiple voxels at once ---
# model.add_voxels([(0, 0, 0), (1, 0, 0), (1, 1, 0)])

# --- Example with non-uniform dimensions and different anchor ---
model_non_uniform = cubeforge.VoxelModel(voxel_dimensions=(2.0, 1.0, 3.0))
# Add a voxel centered at (0, 0, 0)
model_non_uniform.add_voxel(0, 0, 0, anchor=cubeforge.CubeAnchor.CENTER)

# Define output path
output_dir = "output"
os.makedirs(output_dir, exist_ok=True)
output_filename = os.path.join(output_dir, "my_shape.stl")

# Save the mesh as a binary STL file
model.save_mesh(output_filename, format='stl_binary', solid_name="MyCustomShape")

print(f"Saved mesh to {output_filename}")

Examples

The examples/create_shapes.py script demonstrates various features, including:

  • Creating simple and complex shapes.
  • Using different voxel dimensions.
  • Utilizing various CubeAnchor options.
  • Saving in both ASCII and Binary STL formats.
  • Generating a surface with random heights.

To run the examples:

python examples/create_shapes.py

The output STL files will be saved in the examples directory.

API Overview

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests on the GitHub repository.

License

This project is licensed under the MIT License.

This project is developed and maintained by Teddy van Jerry (Wuqiong Zhao). The development is assisted by Gemini 2.5 Pro.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cubeforge-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cubeforge-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file cubeforge-0.1.0.tar.gz.

File metadata

  • Download URL: cubeforge-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cubeforge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c80a808fa71774320399a38ce494963531d82a0e6c906eb6dc8b0346d67e443d
MD5 d7b38b6677ad99bd38fbfdadb4a67f06
BLAKE2b-256 d5d1c3dabfcda646c6e54360304e5d5516e4939c415b2b74f7af3ce841d86507

See more details on using hashes here.

Provenance

The following attestation bundles were made for cubeforge-0.1.0.tar.gz:

Publisher: publish.yml on Teddy-van-Jerry/cubeforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cubeforge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cubeforge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cubeforge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23da257500a11e124edaf731dc5cdf3c6bf21265b74cd60ff934e27e612d6b21
MD5 67b21ba869eba23bc6277474aaa198bd
BLAKE2b-256 805dd8cc3965d5c87cc6d4ee5b8d0dbef3656e08fb8432fa4035bd6d54cf298c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cubeforge-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Teddy-van-Jerry/cubeforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page