← All ideas
  • Published 10 Apr 2021

Apply Dynamic Hair

I'm working with hair particles in Blende want to use the dynmaic hair to make hair be effected by gravity, but I cannot edit it if dynamiv hair is on. I found a script that can apply the furrent frame the hair is in. But affter that do I need to delete the cache, and that is anying.

We need a button to apply dynamic hair on curreny frame.

Link to web page for script:

blender.stackexchange.com/questions/205531/hair-particle-guides-remain-the-same-after-simulation

Here is the script:

import bpy

How to use:

1. edit hair system (important, move at least one hair, at least a bit to initiate hair editing)

2. run hair dynamics

3. move to frame where dynamics should be applied

4. run script

5. if happy, delete cache

6. keep editing hair

get the depsgraph and the evaluated object

deps_graph = bpy.context.evaluated_depsgraph_get() evaluated_object = bpy.context.object.evaluated_get(deps_graph)

assume context object has a particle system (warning, no check), use active

particle_system = evaluated_object.particle_systems.active

Variable to hold hair-verticies-coordinats

hairs = []

At current frame

For each particle (hair)

For each vertex

Store XYZ coordinates

for p in particle_system.particles: hair = [] for v in p.hair_keys: hair.append([ v.co [0], v.co [1], v.co [2]]) hairs.append(hair)

Deactivate hair dynamics

particle_system.use_hair_dynamics = False

On static hair system

For each particle (hair)

For each vertex

Overwrite XYZ coordinates

for p,hair in zip(particle_system.particles,hairs): for v,h in zip(p.hair_keys,hair): #print( v.co , h) v.co [0] = h[0] v.co [1] = h[1] v.co [2] = h[2] #print( v.co , h)

Update view and UI

bpy.context.scene.frame_set(bpy.context.scene.frame_current)

100%

Development Status: Open

Upvote 2 Downvote 0
Xdragon5502
10 Apr 2021

1 Comment

Xdragon5502 Author

mockup

{attachment mockuppng}