# Apply modifier for unwrapping but maintain animation

I have a spring created from a circle with a screw modifier. I'd like to include the coil in the UV unwrapping. If I apply the modifier though, the keyframes from my animation of the coil moving up and down no longer work.

What's the best way to apply this modifier, while still being able to animate the coil?

For reference, I created an animation of the coil similar to what is in this video: https://www.youtube.com/watch?v=nXaVotL8DkY

• I guess you could rig it with one vertical bone, but I'm not sure how to get the weights assigned in an efficient way that would deform correctly. – HISEROD Jan 2 at 22:07
• Duplicate the model. Make the duplicate non-rendering. Apply modifiers on the duplicate. Add a data transfer modifier to the original copying UV from the duplicate on the basis of topology. – Nathan Jan 3 at 1:42

1. Set the spring's skrew distance to the appropriate value for the desired resting position.
2. Run the script below after setting the sides variable to the number of sides of the spring.
import bpy

obj = bpy.context.active_object

sides = 8
steps = obj.modifiers["Screw"].steps
iterations = obj.modifiers["Screw"].iterations

bpy.ops.object.modifier_apply(modifier = "Screw")

group = obj.vertex_groups['Group']

loops = steps * iterations + 1
weight = 0.0

for loop in range(loops):
weight = loop / (loops - 1)
group.add( range(sides*loop, sides*(loop + 1)), weight, 'REPLACE' )

1. After running the script, the skrew modifier will have been applied and a vertex group added with the correct weights.

At this point, you can either use an armature or a control object (with a hook modifier) to deform the spring along the Z axis. In the example below, I have used an empty and a hook modifier to rig the spring:

I wasn't able to get the deformation to work with the armature modifier, but the hook modifier can use bones as well, which worked fine.

• I have done very little with bpy, so if anyone would like to improve my answer don't hesitate to fix any issues. – HISEROD Jan 3 at 1:37
• Thank you -- getting closer. What's the proper way to assign the screw to the armature? Ctrl+P Set Parent To Object? If I do that at the screw object level, it attaches to the armature, but doesn't appear to be weighted. If I attach it to the Vertex Group that the script made, nothing happens when I move the armature. – user1054922 Jan 4 at 1:28
• I tried that as well after reading your comment and edited my solution. – HISEROD Jan 4 at 1:42