SolidWorks Geeks

Sorry for keeping this one longer. There was some other work going on which kept me away from putting this one up but I’m happy to have this one now..

To start you will the spring file you created in the last chapter i.e. HOW TO ANIMATE A SPRING -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. Then I’m going to put another one using a combination of equations and Animator.

Spring Animate.swp (Macro used in this tutorial)

Views: 86

Comment

You need to be a member of SolidWorks Geeks to add comments!

Join SolidWorks Geeks

Deepak Gupta Comment by Deepak Gupta on September 3, 2009 at 6:23am
You can do the same way but you need create your spring as assembly dependent or you can say in context of assembly. Look at this post : https://forum.solidworks.com/message/110524#110524
Mohamed HOUSNI Comment by Mohamed HOUSNI on September 3, 2009 at 6:09am
Yup you are right!

I'm done now thanks for the tutorial!

But I wonder how can we animate a constrained spring within an assembly??
Deepak Gupta Comment by Deepak Gupta on September 3, 2009 at 4:55am
But is hasn't got recorded and that is the reason you macro is not doing anything. Try doing it again i.e. start recording and then repeat steps 3, 4 and 5.
Mohamed HOUSNI Comment by Mohamed HOUSNI on September 3, 2009 at 3:33am
Hello!

Yes I am sure I did changed the height of the spring as indicated ..
Deepak Gupta Comment by Deepak Gupta on September 2, 2009 at 10:26pm
You haven't record anything except for the frame state. Did you after starting the recording, changed the spring height as indicated in step 3, 4 and 5.
Mohamed HOUSNI Comment by Mohamed HOUSNI on September 2, 2009 at 3:25pm
Hello Deepak,

Here's the macro I get, its code is not the same as that you give above Macro1.swp
Deepak Gupta Comment by Deepak Gupta on September 2, 2009 at 1:44pm
You need to make sure you have the same parameter/dimensions name. If you still have error, send in you file and I will let you know where is the issue.

Deepak
Mohamed HOUSNI Comment by Mohamed HOUSNI on September 2, 2009 at 11:57am
hello,

I don't get the same code as shown above, and even by using the code in Spring Animate.swp I don't get any result!

What can I do!

thank you in advance!

Connect to other SolidWorks Geeks throughout the world.... Share tips, tricks and ideas...Learn to master SolidWorks.

© 2012   Created by Alex R. Ruiz.   Powered by .

Badges  |  Report an Issue  |  Terms of Service