How can a spring be animated in SOLIDWORKS?

This article will illustrate how to animate flexible components in SOLIDWORKS. A spring will be used in the example.

Have you ever wondered how to create an animation that included a component that deformed? The technique involves creating a part in the context of an assembly, which you may already know how to do. In our example, we will show how a spring can be compressed and uncompressed during the animation sequence.

animating

Figure 1: The completed piston assembly.

For the sake of adhering to the topic at hand, and for the sake of brevity, this article assumes the reader understands how to create components in the context of an assembly. We will also assume a basic understanding of swept features and using the motion manager to create simple animations.

animating

Figure 2: In-context sweep path.

Looking at Figure 2, we can see the sweep path, which is the most critical part of this demonstration. The ends of the piston (the blocky shapes) have already been mated into position. The piston component (the small cylinder with O-ring grooves) has a distance mate (not shown) which controls how far the piston face is from the face of the block on the right. The right endpoint of the line is coincident with the face of the block.

The small .1” construction line on the left is collinear with the line and its left endpoint is coincident with the face of the piston. The reason for the construction line is to control where the sweep path ends (or begins, depending on how you want to look at it). This allows room for the resultant spring feature to exist so it doesn’t embed itself into the piston. In essence, the .1” construction line creates room for the .1” diameter sweep profile.

animating

Figure 3: Sweep path and completed spring.

Figure 3 shows the sketch used for the sweep profile. It also shows what the completed spring looks like after cleaning things up with a couple revolved features. After creating the initial in-context sweep path sketch, feel free to open the spring in its own window to finish working on it. Not only does this cut down on screen clutter, it helps to keep extra, unnecessary external references from being accidentally created.

It's worth noting a helical path was not used for the sweep path. Rather, twist was added during the sweep operation (a total of 6 turns) to quickly and easily generate the spring.

The next critical factor in getting our spring to compress is to create key frames for the distance mate that controls the piston position. Figure 4 shows an example of this. It is necessary to expand the mates folder and locate the appropriate distance mate. Renaming the mate to “Piston Distance” made this task easier.

Flexible components4-1

Figure 4: Creating key frames for the piston distance mate.

 Next, key frames are created at 1 second intervals for 7 seconds. This is all done via the right mouse button in the Motion Manager (again, we are assuming a basic understanding of animation within SOLIDWORKS at this point). The spring starts in the uncompressed position and is then compressed 4 times.

Once the key frames are in position, move the time bar to the first key frame and set the mate distance to the desired value. Repeat this process for all key frames. In our example, the key frame at 1 second sets the distance between the piston face and the face of the block to .8” (compressed). At 2 seconds, the distance is set back to the original value of 2.25” (uncompressed). At 3 seconds, the distance returns to .8”, and so on. The end result is the spring expanding and compressing a total of 4 times. At the 7 mark, it will stay compressed for 3 seconds.

Two additional key frames were added at the end of the animation, as shown in Figure 5. Here again, it's a matter of properly positioning the time bar, adding a key frame, double clicking to pull up the Piston Distance dimension, and setting the dimension to the appropriate value. 

Flexible components4

Figure 5: The spring is compressed at the 10 second mark.

In Figure 5, the key frame was copied from the 7 second mark and pasted in at the 10 second mark. The dimension was left at it's "compressed" value of .8". That is why there's no transition bar between the keys at 7 and 10 seconds. After adding a key at the 12 second mark, the dimension is set to the uncompressed value of 2.25", as shown in Figure 6.

Flexible components5

Figure 6: The spring is uncompressed at the 12 second mark.

Many flexible components can be animated in such a fashion. The key is to create the component in the context of an assembly, and to control component positioning with mates. The "litmus"  test is that if the mate(s) can be changed and the flexible component changes shape accordingly, it can probably be animated.

Calculating the Animation and Playback

During the calculation phase of the animation, any time the in-context component requires a rebuild to display properly, SOLIDWORKS will go ahead and rebuild the assembly. Unfortunately, there is no internal limiting factor that will force rendering to pause each frame while the rebuild is taking place. Therefore, segments of the animation where components are being moved or rotated will play back fine, while segments of the animation where components are being rebuilt will appear choppy. Frame rates will suffer terribly.

To get around the choppy frame rate issue, it is necessary to save the animation as a movie file. The informational message shown in Figure 7 will ask if you would like to use “accelerated rendered animation processing”. It will be necessary to click No, forcing the renderer to use the slower animation processing, which allows a rebuild to occur at every frame. This is precisely what we need to obtain the “deformation” of our component.

aniamting

Figure 7: Clicking No uses standard animation processing.

Here is a short clip of the piston in action, showing the spring deforming.