The tbpy.convert module provides utilities to convert between Blender mesh data and trueform tf.Mesh objects. Use these for standalone scripts where you don't need caching.
Convert a Blender mesh or object to a trueform Mesh:
from trueform import bpy as tbpy
# From object (applies world transform)
mesh = tbpy.convert.from_blender(obj)
# From mesh datablock (no transform)
mesh = tbpy.convert.from_blender(obj.data)
Automatically builds spatial tree, face membership, and manifold edge links required for most operations (e.g., booleans).
Parameters:
| Parameter | Type | Description |
|---|---|---|
data | bpy.types.Mesh or bpy.types.Object | Blender mesh datablock or mesh object |
Returns: tf.Mesh with all required structures built.
Create a Blender mesh object from a trueform Mesh:
from trueform import bpy as tbpy
# Create new Blender object in active collection
obj = tbpy.convert.to_blender(mesh, name="Result")
# With smooth shading
obj = tbpy.convert.to_blender(mesh, name="Result", flat_shading=False)
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
mesh | tf.Mesh | Trueform mesh to convert | |
name | str | "Mesh" | Name for object and mesh datablock |
flat_shading | bool | True | Use flat shading on faces |
Returns: bpy.types.Object linked to the active collection.
Create a Blender curves object from paths and points:
from trueform import bpy as tbpy
import trueform as tf
# Get intersection curves
paths, points = tf.intersection_curves(mesh_a, mesh_b)
# Create Blender curves object
curves_obj = tbpy.convert.to_blender_curves(paths, points, name="Curves")
Parameters:
| Parameter | Type | Description |
|---|---|---|
paths | OffsetBlockedArray | Paths as indices into points array |
points | np.ndarray | (N, 3) array of point coordinates |
name | str | Name for object and curve datablock |
Returns: bpy.types.Object with curve data, linked to active collection.
These functions provide finer control over the conversion process.
Extract vertices and triangulated faces from a Blender mesh:
points, faces = tbpy.convert.extract_geometry(mesh_data)
# points: (N, 3) float32 array
# faces: (M, 3) int32 array of triangle indices
Create a Blender mesh datablock from numpy arrays:
mesh_data = tbpy.convert.make_polygons(faces, points, name="Mesh")
# Returns bpy.types.Mesh (not linked to any object)
Create a Blender curve datablock from paths and points:
curve_data = tbpy.convert.make_curves(paths, points, name="Curves")
# Returns bpy.types.Curve (not linked to any object)
Complete example of a standalone boolean script:
import trueform as tf
from trueform import bpy as tbpy
import bpy as blender_bpy
# Get selected objects
selected = blender_bpy.context.selected_objects
if len(selected) != 2:
raise ValueError("Select exactly 2 mesh objects")
obj_a, obj_b = selected
# Convert to trueform
mesh_a = tbpy.convert.from_blender(obj_a)
mesh_b = tbpy.convert.from_blender(obj_b)
# Compute boolean difference with curves
(faces, points), labels, (paths, curve_points) = tf.boolean_difference(
mesh_a, mesh_b, return_curves=True
)
# Create result mesh
result = tf.Mesh(faces, points)
result_obj = tbpy.convert.to_blender(result, name="Boolean_Result")
# Create intersection curves
if len(paths) > 0:
curves_obj = tbpy.convert.to_blender_curves(paths, curve_points, name="Intersection_Curves")
curves_obj.data.bevel_depth = 0.01 # Make curves visible
# Hide input objects
obj_a.hide_set(True)
obj_b.hide_set(True)