Tag Archives: Macro

Show your SOLIDWORKS API Skills to Win $100

CADSharp is happy to announce the second SOLIDWORKS API programming contest!

The problem is simple and you need to write the codes to achieve the desired results. Hurry up to submit your codes before July 1, 12:00AM EST.

Get Contest Details Here

Three winners will be chosen based on the number of lines of code in their macro.

First prize: $100 gift card at Amazon.com.
Second prize: $50 gift card at Amazon.com.
Third prize: $50 gift card at Amazon.com.

Note: The Amazon gift cards can only be awarded to entrants who may purchase Amazon.com or one of its affiliates in Australia, Canada, United Kingdom, Germany, Italy, France, Spain, Netherlands, China, Brazil, India, Mexico, and Japan. Otherwise, a 2-month Power User membership (valued at $199) will be awarded instead. Optionally, a winner that is entitled to a gift card may choose to receive the 2-month CADSharp Power User membership instead.

Learn SolidWorks API while you Watch!

Macros are small programs in SolidWorks which allows to do lot of repeated or complex stuff in very short time. In other words you can take a coffee break while that tiny Macro is working for you and you get the salary for that work. Looks interesting, then read on..

Pre-requisites to learn SolidWorks API

Just a combo of SolidWorks and a Programming language (VB, VB.NET, C#, and C++) can make you API master. I prefer VB not because I feel it is more simple but I can understand a bit of it.

Recently I flipped over CADSharp and found a massive Video library teaching how to play with SolidWorks macro along with huge Macro library with many free examples.

About CADSharp

Keith, a former SolidWorks application support engineer, created CADSharp.com to help others learn the SolidWorks API quickly and painlessly.

How to access the hidden (actually not hidden but free) resources 

What CADSharp has to offer

Lot of interesting and helpful articles on SolidWorks API and VBA. Find them here


But that has not ended yet, CADSharp.com is proud to announce its upcoming SolidWorks API training webinars for the month of June, 2012, covering a range of important API topics. Register now and  Learn SolidWorks API while you Watch!

Time to Study and Learn with SolidWorks

I’ve been quite a busy these days after I’ve returned from SolidWorks World 2012 in San Diego. I’ve been working on many things and don’t get much time to write. And to add to this I’ll be busy for next few weeks. This would not be only because of my ongoing projects but also something different, I’m getting back to my school days.

I’m not going to join any school though but will be doing a self learning. I’ll be doing my favorite stuffs in SolidWorks which are Rendering, Animation and API. I’ll be studying and learning via following books in next couple of weeks.

Photorealistic Rendering Using SolidWorks and PhotoView 360

(Courtesy of Rob Rodriguez)

Creating Animations with SolidWorks Step-by-Step

(Courtesy of SolidWorks)

SolidWorks API – Programming & Automation

(Courtesy of Luke Malpass)

SolidWorks API – Advanced Product Development

(Courtesy of Luke Malpass)

I’ll be posting my learning experience with these books soon.

Export OBJ out of SolidWorks for free!!

I don’t work much with file export into various format but getting across a free OBJ export tool from Neil Larsen and macro-maker Karpena, I thought it might be good thing to spread across the SolidWorks community.

Neil Larsen has shared a free macro, suitable for SW2005 and up, to export your models in Alias|Wavefront .obj format complete with .mtl and textures. The macro works with parts and assemblies and configurations. It has been made to enable SolidWorks models to be rendered in cg applications such as Blender and Octane Render. As of the time of this post Blender 2.62 and Octane beta2.57 are current.

The macro can be can downloaded from here. It comes to you courtesy of karpena, who wrote the basis of the macro, and yours truly who extended it and gave it a UI. The zip contains the necessary files and instructions. Please be sure to read the README about the ins and outs of installing/using the macro. This macro won’t as a rule be supported but if there are teething issues with this release please report them here.

Neil does request everyone who so ever uses this macro,“All we ask, aside from not to sell it, is that you make sure any variants in the wild have some distinction in the name so that its clear which macro is for which apps and not confuse revisions. Its sort of in keeping with the spirit of open source because both Roman (karpena) and I make use of Blender.”

INSTALLATION:

The SW macro can go anywhere but conveniently where you keep your other SW macros. You will need to use the provided toolbar button to launch the macro from SW. See the SW Help>Macros>Customize buttons to find out how to set this up. See also the included picture of the custom button showing to select the modSWtoOBJ.InitialUI as the ‘Method’ to start.

NOTE: The macro will not run from the menu Tools/Macro/Run> or from the toolbar Macro>Run.

The macro included was authored in SW2009. Different SW versions will require you to open the macro in the SW MS VBA window, reselect the Reference Libraries appropriate to that version, andthen save the macro. See the included ‘References’ picture of SW2009. Opening in another version may show the References as being ‘MISSING’. Look down the list and find equivalent entries but for the year of your SW install. Sometimes SW will find these references itself. The Blender helper script is required to load the finished .obj into Blender automatically.

It should work with Blender 2.5 and up. Make sure it goes in the same folder as the Blender.exe . The path to Blender is assumed to be C:\Program Files\Blender Foundation\Blender\blender.exe

The path to Octane is assumed to be C:\Program Files\Refractive Software\OctaneRender\Octane.exe

You can change these paths if necessary in the vba module code by going to lines 627 & 632 respectively.

Here is one example of OBJ export (you can find them in the zip file too).

Happy rendering!

Some New SolidWorks Macros to tangle with

Recently I posted some new SolidWorks macro at Lorono’s SolidWorks Resources which you would like to try and might find useful for your day to day use.

Here are brief details on the macros:

Send Email via SolidWorks : Macro to send email with assembly name in subject.

Save and Open as PDF:  Macro to save active file as PDF in the same location and open the created PDF file

Hide Show Note : Macro to hide or show note in the active drawing.

There are more useful macros and stuff at Lorono’s SolidWorks Resources and I’ll be adding more similar macro there, so keep watching.

HOW TO ANIMATE A SPRING -2

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.
as31

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