0
$\begingroup$

I need a Python script to change simulation frame start/end of a particle system, as i use a stylised hair system where each strand has its own object and to bake them all i'd have to selected each individual one and change there start and end. i have a script that actually Bakes all the selected objects at once but it doesnt have anything to change the start and end.

import bpy




def print(data):
    for window in bpy.context.window_manager.windows:
        screen = window.screen
        for area in screen.areas:
            if area.type == 'CONSOLE':
                override = {'window': window, 'screen': screen, 'area': area}
                bpy.ops.console.scrollback_append(override, text=str(data), type="OUTPUT")

print("1")
# Check if there is an active object


obj = bpy.context.object

for scene in bpy.data.scenes:
    for object in bpy.context.selected_objects:
        for modifier in object.modifiers:
            if modifier.type == 'FLUID':
                print('fluid')
                #if modifier.fluid_type == 'DOMAIN':
                    #print("Baking fluid")
                    #object.select_set(True)
                    #bpy.context.view_layer.objects.active = object
                    #bpy.ops.fluid.bake_data()
            elif modifier.type == 'CLOTH':
                print("Baking cloth")
                #override = {'scene': scene, 'active_object': object, 'point_cache': modifier.point_cache}
                #bpy.ops.ptcache.free_bake(override)
                #bpy.ops.ptcache.bake(override, bake=True)
            elif modifier.type == 'PARTICLE_SYSTEM':
                print("Baking particlesm")
                override = {'scene': scene, 'active_object': object, 'point_cache':                  modifier.particle_system.point_cache}
                bpy.ops.ptcache.free_bake(override)
                bpy.ops.ptcache.bake(override, bake=True)
#bpy.ops.wm.save_mainfile()
$\endgroup$
3
  • $\begingroup$ what did u try so far? pls post at least your script try, so we don't have the impression that you are just looking for someone who does your job. thx. $\endgroup$
    – Chris
    Commented Feb 27 at 14:52
  • $\begingroup$ and another thing: you did never accept an answer you got here: [1]: i.sstatic.net/MSfQz.png which could make some people think you are a bit unthankful. And marking an answer as accepted (pressing the checkmark left of an answer) is also very useful for other users so they know that the answer is helpful. Thx for your understanding. $\endgroup$
    – Chris
    Commented Feb 27 at 14:54
  • $\begingroup$ i've edited the post it to include the script so far, and i'll get to those awnswers now $\endgroup$ Commented Feb 27 at 15:06

1 Answer 1

0
$\begingroup$

I added this piece of code after

print("Baking particlesm") towards the bottom

and it seems to have worked

~~

            strands = bpy.context.selected_objects
            for x in strands:x.modifiers["ParticleSystem"].particle_system.point_cache.frame_start=10
            
            for x in strands:x.modifiers["ParticleSystem"].particle_system.point_cache.frame_end=14

~~

$\endgroup$

You must log in to answer this question.

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