0
$\begingroup$

Hi Blender Python users!

I was just wondering if anyone knows a way to key frame the particle size of a smoke flow particle system over time with a python script.

For example: I would like to change the flow settings particle size to start at size=1 and end at size= 0.1

Great community here! Thanks for your help!

Right now my script looks like this.

        bpy.ops.object.modifier_add(type='SMOKE')
        bpy.context.object.modifiers["Smoke"].smoke_type = 'FLOW'
        bpy.context.object.modifiers["Smoke"].flow_settings.smoke_flow_type = 'FIRE'
        bpy.context.object.modifiers["Smoke"].flow_settings.smoke_flow_source = 'PARTICLES'
        bpy.context.object.modifiers["Smoke"].flow_settings.particle_system = bpy.data.objects["Smoke/Fire Particle Emitter"].particle_systems["ParticleSystem"]
        bpy.context.object.modifiers["Smoke"].flow_settings.use_initial_velocity = True
        bpy.context.object.modifiers["Smoke"].flow_settings.velocity_factor = 0.2
        bpy.context.object.modifiers["Smoke"].flow_settings.use_particle_size = True
        bpy.context.object.modifiers["Smoke"].flow_settings.particle_size = 1.2
        bpy.context.object.modifiers["Smoke"].flow_settings.subframes = 50
        bpy.context.object.modifiers["Smoke"].flow_settings.use_absolute = False
$\endgroup$

1 Answer 1

1
$\begingroup$

Script for blender 2.79 with a few options.

import bpy

keyframes = [1,10,20,30]
object = bpy.context.active_object

frame = 50
value = 3.14159265

grouped = [(70,10), (80, 9), (90, 5), (100, 1)]

def incremmental_add(obj, frmlst):
    for frame in frmlst:
        obj.modifiers["Smoke"].flow_settings.particle_size += 1.0
        obj.keyframe_insert(data_path='modifiers["Smoke"].flow_settings.particle_size', frame=frame)

def single_frame(obj, frm, val):
    scn = bpy.context.scene
    scn.frame_set(frm)
    obj.modifiers["Smoke"].flow_settings.particle_size = val
    obj.keyframe_insert(data_path='modifiers["Smoke"].flow_settings.particle_size', frame=frm)

def tuple_list(obj, frame_n_val):
    for i in frame_n_val:
        single_frame(obj, i[0], i[1])

incremmental_add(object, keyframes)

single_frame(object, frame, value)

tuple_list(object, grouped)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .