How to animate a spring - Part 2

Publié le 10 juin 2009 par Clement Donzel

Here is part two of Spring Animation. To start you will the spring file you created in the last chapter i.e. How to animate a spring - Part 1.

1. Open the spring part file.
2. Click on the Record button on the macro tool bar. If you haven’t have the macro toolbar one, you can go to Tools > Macros > Record to start recording. To show the macro toolbar go to View > Toolbar > Macro.

3. Double click on the spring body to show the dimensions and then click on the length, 100 mm in this case if you used the same old spring part file.

4. In the pop up window change the value to anything > I have changed it to 110 mm.

5. Click on Rebuild in the same dimension box or from the toolbar.

6. Finally click Stop on the macro toolbar or Tools > Macros > Stop.

7. Give a name your macro and hit save. I have used Spring Animate.

8. Now click on Edit button on macro toolbar or Tools > Macros > Edit

9. Browse to the macro you saved in the step 7 and open it.

10. VB editor will get open up and your screen will look like this.

11. Remove the extra line and make your window look like this.

12. Copy these 3 highlighted lines and paste them.

13. The editor window will look like this. Change the system value to .1. The system takes all in puts in meter. So if you want any other value convert it to meter and put here. .1 denotes .1 m i.e. 100mm

14. Add these 4 lines as shown and save you macro. You can keep any value for “i”. In this case I have used 10 which means the macro will run for 10 times. You can give any value or can create an input box where user can put the number of steps he needs. I will put up a macro or tutorial on how to do that.

15. Close the VB editor and back to SolidWorks window. Click on Play button on macro toolbar or Tools > Macros > Play

16. Browse to the macro you edited and saved in step 14.

17. Now sit back and enjoy the animation.

Apart from using macro, I have been trying to use Phil Sluder’s trick (SW Tips/Tricks - July Issue Adding Logic to Equations) but getting some error. I have requested Phil to check the same. As soon as he fixes as where I’m going wrong, we can have animation of spring using equations too. I’m also going to put another one using a combination of equations and Animator.

Link for the macro used in this tutorial: Spring Animate.swp