3

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

bpy.ops.mesh.primitive_circle_add( radius=1, 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.ops.object.particle_system_add()

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

Hemisphere with Particles

Image: Final output required with cell fracture

Hemisphere with cell Fracture

Thanks and Regards,

Sunag R A.

batFINGER
  • 84,216
  • 10
  • 108
  • 233
rasunag27
  • 47
  • 6
  • It is \`` for the code block (under esc key), your are using'` (beside enter key) – HikariTW Jul 31 '20 at 06:19
  • 1
    @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 09: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

1 Answers1

3

enter image description here

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(
bpy.ops.object.add_fracture_cell_objects(source={'PARTICLE_OWN'},
        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
from addon_utils import enable

make sure cell fracture is enabled

enable("object_fracture_cell")

context = bpy.context

Draw hemisphere of 1 m radius

bpy.ops.mesh.primitive_circle_add( radius=1, 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

bpy.ops.object.add_fracture_cell_objects()

batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • 1
    Thank you so much..!! This gives me the clarity of coding in Blender and also the solution to my problem. – rasunag27 Aug 04 '20 at 04:57
  • 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 '21 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 '21 at 19:16
  • Any possibility of defining the size of each fracture area? this could be useful to create voronoi treemaps – Pedro Jun 12 '23 at 13:06