# How to create cell fracture in python

Firstly, I am new to Blender. I am actually working on to create a hemispherical model with cell fractured property.

1. I have done this work manually using cell Fracture add-on and now I want to automate using python.

2. I have written the code till particle implementation on the hemisphere. Now I want to create a cell fracture with those 100 particles.

I have attached the hemisphere picture and the final output needed. I have also attached the code. Please provide me an insight on how to do this using python.

Code till Particles in Hemisphere:

import bpy

# Draw hemisphere of 1 m radius
enter_editmode=True,
align='WORLD',
location=(0, 0, 0),
fill_type='TRIFAN',  # NOTHING  or NGON
)

bpy.ops.mesh.bisect(
plane_co=(0, 0, 0),
plane_no=(0, -1, 0),
clear_inner=True,
)

# Particles
bpy.ops.object.editmode_toggle()

bpy.data.particles["ParticleSettings"].count = 100

bpy.context.object.particle_systems["ParticleSettings"].seed = 1

bpy.data.particles["ParticleSettings"].frame_end = 1


Image: Hemisphere with particle feature

Image: Final output required with cell fracture

Thanks and Regards,

Sunag R A.

• It is  for the code block (under esc key), your are using ' (beside enter key) – HikariTW Jul 31 '20 at 6:19
• @HikariTW recommend tab formatting for code block (ie all of code block tabbed one extra right) Wrapping in three backticks often leave a residual when copy / pasting. – batFINGER Jul 31 '20 at 9:23
• @batFINGER But I prefer using explicit bracket for code since there is no standard tabbed lens and in some editor, block tab just don't do the work. (And the residual should be considered as parser and html implement method?) – HikariTW Jul 31 '20 at 16:12

Add particle system as suggested here Python and particle system

Make sure the cell fracture addon is enabled, and call the operator

bpy.ops.object.add_cell_fracture_objects()


Which uses defaults as mapped out in doc string

>>> bpy.ops.object.add_fracture_cell_objects(
source_limit=100,
source_noise=0,
cell_scale=(1, 1, 1),
recursion=0,
recursion_source_limit=8,
recursion_clamp=250,
recursion_chance=0.25,
recursion_chance_select='SIZE_MIN',
use_smooth_faces=False,
use_sharp_edges=True,
use_sharp_edges_apply=True,
use_data_match=True,
use_island_split=True,
margin=0.001,
material_index=0,
use_interior_vgroup=False,
mass_mode='VOLUME',
mass=1,
use_recenter=True,
use_remove_original=True,
collection_name="",
use_debug_points=False,
use_debug_redraw=True,
use_debug_bool=False)
(undocumented operator)


Test code, produces result as in image above.

import bpy

# make sure cell fracture is enabled
enable("object_fracture_cell")

context = bpy.context

# Draw hemisphere of 1 m radius
enter_editmode=True,
align='WORLD',
location=(0, 0, 0),
fill_type='NGON',  # NOTHING  or NGON
)

bpy.ops.mesh.bisect(
plane_co=(0, 0, 0),
plane_no=(0, -1, 0),
clear_inner=True,
)

bpy.ops.object.editmode_toggle()

# Particles

ob = context.object
ps = ob.modifiers.new("Part", 'PARTICLE_SYSTEM').particle_system
ps.seed = 1
ps.settings.count = 100
ps.settings.frame_end = 1

# cell fracture


• I was trying the code provided by the chosen answer on Blender 2.92 which was failing, the needed change is to use add_fracture_cell_objects instead of add_cell_fracture_objects. – Anas Einea Mar 22 at 15:26
• Thanks for the heads up. The cell fracture in the version of 2.92.0 RC` I am using is still working as above. What version of 2.92 did you notice change in?. – batFINGER Mar 22 at 19:16