SolidWorks Macros
SolidWorks Macros
SolidWorks Macros
Files:
-

Area Solver
- Downloads:
- 31
This macro will take a part with 2 bodies and alter the required dimension to an accuracy of 8dp so that the areas of the 2 bodies is identical. Find attached sample SolidWorks part to test the macro on.
-

Auto-create Drawing from Model
- Downloads:
- 174
This macro with one click creates a drawing with 3 common views and an isometric view, aligns them and inserts all dimensions onto the 3 standard views, and saves it to the same location as the model.
-

Bulk Change Part Material
- Downloads:
- 75
A macro to change bulk Part Material. The macro will open each part, change the material, rebuild, save and close the file.
Change the material and if required change the database too.
' Prerequisites: Set the directories having part files you wish to change the material
Macro will find all the part files in the specified folder/location and change the material to specified one. -

-

Create Flat Pattern Drawing
- Downloads:
- 147
For those of you who have to produce flat pattern DXFs for production (laser/plasma) cutting or the likes, you may be using tools such as Lantek or manually creating your own sheets with flat-pattern views at a 1:1 scale.
This macro will automatically create a new sheet at 1:1 scale and place a flat pattern view on it with the click of a button. From ther it will then prompt you whether you would like it to go ahead and save the flat pattern to DXF for you, and finally whether to delete the flat pattern sheet it created once done.
The macro now automatically removes hole centre notes and bend lines etc...
PS. Once you have the flat pattern sheets created in your drawings, you could also use BatchProcess to automatically create all the profile sheets for you in any format (i.e. DXF, DWG) in one go. -

Delete Design Table
- Downloads:
- 32
This macro is nice and simple; it deletes the currently active models design table
-

Equation Editor
- Downloads:
- 57
This is a simple tool that mimics the "Edit All" equation options of a model just like SolidWorks... only this one works.
-

Export BOM
- Downloads:
- 128
You have two methods for extracting BOMs to Excel. One is the in built function of SolidWorks, and the second is the manual way to creating exactly what you want in an Excel sheet.
The attached Macro does performs both.
Make sure you check that your References... are setup to your version of SolidWorks & Excel (Current example is SW2008 & Excel 2007):
You may use this macro however you wish, I only ask you leave the commented credits within the macro.
If you wish to save each BOM under the name of a value from the custom properties, such as $PRPSHEET:{Description}, you would modify the code to get the bomPath as follows:
Code:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim valOut As String
Dim resolvedValOut As String
Dim config As SldWorks.Configuration
Dim cpm As SldWorks.CustomPropertyManager
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set cpm = swModel.Extension.CustomPropertyManager("")
If Not cpm Is Nothing Then
cpm.Get2 "description", valOut, resolvedValOut
End If
Now with resolvedValOut you may use that as the filename in any way you wish. -

Export Flat Pattern View
- Downloads:
- 89
Preconditions: A Sheet metal part is open.
Postconditions: Macro will export flat pattern view for all configuration(s) and save as dxf in the same location. -

Feature Tree to Clipboard
- Downloads:
- 58
This macro is a simple one to copy the active documents feature tree directly to the clipboard.
-

Find Center
- Downloads:
- 29
This macro will find the center of any number of selected sketch points and either add a point at that position, or inform the user via message box.
-

Flattern Layers
- Downloads:
- 29
This macro will delete all the current layers (contents of layers are not deleted) and 5 layers with Color Red, Black, Green, Yellow and Brown with Line style as Solid and Thickness as 0.0138 will be added.
-

FuncPlot
- Downloads:
- 49
Mahir Abrahim has created 2 very useful macros that can create 3d curves, spirals, surfaces and more based on given equations. Very useful!
*FuncPlot
Description: Automates the plotting of 3D curve functions. Equations can be input using Cartesion, cylindrical, or spherical coordinates. Can create either curves or 3D sketches. Also has the option of exporting 3D data points. Uses Excel for calculations.
Precondition: Part or Assembly open
Postcondition: 3D curve or sketch createdQuote:
[Note: t can only be evaluated from 0 to 1. However, you can easily get around this. If you want your function's domain to be [A,B], then replace any instance of "t" with "(B-A)*T - A". ] -

Get Component Colors
- Downloads:
- 41
This macro is very simple. It gets/sets the color values of the selected component within an assembly.
-

Get Part Colors
- Downloads:
- 43
This macro is much like the Get Component Colors macro, except it traverses a single part, and gets all body and face color information, then selects each entity and displays its color properties in a message box.
-

Get Point Coordinates
- Downloads:
- 54
This macro gets the coordinates of a selected sketch point in a model and sets a custom property to that value.
There is no error checking in this macro so feel free to add it yourself. -

Hide or Show Any Tables
- Downloads:
- 29
This macro shows you how to change the visibilty of any table in a drawing sheet. Have fun!
-

Import Table
- Downloads:
- 108
This macro is in high demand. Using it you actually IMPORT any Excel sheets (such as exported BOMs or any sheets you wish) directly into a SolidWorks drawing.
To use it simply open the SolidWorks drawing you wish the table to be imported into, and open the Excel file you wish to import.From there, highlight in Excel the data you wish to import, then go back to SolidWorks and run the macro.


Don't forget to alter the references to your version of Excel and SolidWorks, and keep all original credits to AngelSix. Enjoy!
This macro has now been updated to import cell formatting, font formatting, alignment and colum/row widths and heights to give a more full import! -

Increment Angle
- Downloads:
- 32
This macro increments a specific Angle mate each time it is run, by a set amout of Rads or Degree.
-

Mass Alter Dimensions
- Downloads:
- 37
This macro will mass alter all of the selected dimensions by a set amount, or by a percentage of their original value, or both, and another version has added multiply, division, addition and subtraction.
-

Save As Part Number
- Downloads:
- 52
Description: Macro to save existing part files in the specified folder/location, to a new location with specified custom property value as part name. Part Number is used as a Custom property in this macro.
Pre-Conditions: Set the directories for opening the part from and saving to new location. Part files exist in the specified location.
Post-Conditions: New part files with specified custom property value as part name. Macro will overwrite any existing part with same name. -

Save As PDF
- Downloads:
- 74
This macro will save all drawing sheets as PDF files, one PDF per sheet.
As usual no error checking has been done I will leave that up to you lot. -

Set Bulk Material
- Downloads:
- 47
As many of you probably know. You cannot select parts from in an assembly and set their material without having to open them first.
With this macro, you can simply select any parts in the assembly, select the appropriate material, and then click a button to have the material set in all selected parts.
I have left room for expansion and improvement in this macro for ease of understanding. Any modifications, please credit AngelSix for the original macro. -

Set Component Names
- Downloads:
- 50
This macro will loop all components within an assembly and set their Component Name to that of any custom property value within each part. So for example you can set the Component Names to equal whatever the parts "Description" custom property is set to.
This is useful when exporting as eDrawings as eDrawings will always show the Component Names. -

Set Document Arrows
- Downloads:
- 45
This macro is short and sweet. With one click sets the current documents Arrow formats up to whatever you specify within this macro. This is ideal for updating old templates to the new standards.
-

Set Document Font
- Downloads:
- 45
This macro is similar to Document Arrows. With one click sets the current documents Font styles to whatever you specify within this macro. This is ideal for updating old templates to the new standards.
-

Set Thickness Property
- Downloads:
- 41
If run within a sheet metal part, this macro will automatically set the "Thickness" field in the models custom properties to the thickness of the sheet metal.
If run in a normal model, select a dimension you wish to be set as the thickness prior to running this macro, and that dimension will be set as thickness. -

SurfPlot
- Downloads:
- 38
Mahir Abrahim has created 2 very useful macros that can create 3d curves, spirals, surfaces and more based on given equations. Very useful!
*SurfPlot
Description: Automates the creation of surfaces from 3D surface functions. Equations can be input using Cartesion, cylindrical, or spherical coordinates. Can create either surfaces and/or curve sets. Uses Excel for calculations.
Precondition: Part open
Postcondition: Surface or curve set created
Quote:
[Note: t can only be evaluated from 0 to 1. However, you can easily get around this. If you want your function's domain to be [A,B], then replace any instance of "t" with "(B-A)*T - A". ] -

Toggle Units
- Downloads:
- 45
This macro will toggle the document units between metric and imperial on each click.
-

Traverse Through Features
- Downloads:
- 58
This macro is a good example of part traversal; it loops through all features of a part and performs operations on them based on conditions.
This specific example loops through a part and suppresses any fillets that are less that X mm.
This can be easily expanded to work on assemblies too.
X2 - Blue LCD monitor for PCs
BatchProcess THE automation tool
SaveAsX
LaserMRP
Property Extractor
Property Wiper
Engineering Toolbox
SWTools
Config Searcher
Circle Centers
3D Matrix
Fuel Economy Calculator
GUID Creator
SolidWorks API Books
SolidWorks Macros
Tutorials
Message Boards
Game Studio Art
Clients & Testimonials
Contact Us