It’s that moment you’ve been waiting for. That moment where your coworker pick his keyboard up, drops it, picks it up again and lifts it over his head. You would like to tell him about a couple SolidWorks Macros that would help him out, buuuuuuuut you’re being entertained and office rage is content YouTube is just hollering for.
On the less antagonizing side, there’s you showing your office buddy how to avoid fits of unnecessary rage by offering two shiny macros for the low price of “sit down and shut up for a few minutes while I show you this friend.”
He smiles. One less lo-fi video of your crazy friend on the web.
The missing keyboard shortcuts
SolidWorks comes with the ability to assign almost every command to a keyboard shortcut. However, there’s no keyboard shortcuts for Mates. Here’s two macros for the most common mates and how to reduce the amount of that annoying mouse button clickin’ to speed up your assembly construction.
Coincident Mate – Download Coincident Macro
This SolidWorks macro runs the recorded process of adding a Coincident mate between two planar selections. To use it, select two faces and run the Macro. If the selections are compatible, you’ll have a Coincident Mate without having to go through the Mate Properties dialogue.
Concentric Mate – Download Concentric Macro
This SolidWorks macro runs the recorded process of adding a Concentric mate between two cylindrical selections. To use it, select two faces and run the Macro. If the selections are compatible, you’ll have a Concentric Mate without having to go through the Mate Properties dialogue.
Save these macros to the location you store your macros. I recommend having a directory on your network so everyone is able to access them. I actually set the path for Macros up in Tools, Options, File Locations so its the same for each install of SolidWorks.
How to Assign Hotkeys to Macros
This will make mating things up even faster. I assign the Coincident Mate to ‘G‘ and the Concentric Mate to ‘H‘ and since my hand is usually on that area of the keyboard it makes for some blazing fast assembly construction. Here’s the step-by-step:
- Right-click on Toolbars, Customize
- Select the Command Tab
- Select the macro Category
- Drag the Macro Icon
to a Toolbar - In the pop-up, under Action browse to the Macro
- In the Shortcut Box, addthe keyboard shortcut you want to use
You can do this with other Macros you have as well. It save some clicking and it saves some moving around, but most of all it speeds up a very repetitive process. What Macros do you set up on the keyboard?



SolidSmack is a very small behemoth of an online community about 3D CAD, technology, design, robots, and ninjas… Ok, maybe not ninjas so much, but those guys are COOL so there just might be something about some dang ninjas.
{ 24 comments }
Josh, you are slowly forcing me to become more efficient. I enjoy that.
Rod, you are slowly forcing me to respond to more comments! keep'em coming man, love it. and really glad you found this useful. Not sure why I haven't posted it already. see ya!
Mates are already pretty quick with a keyboard shortcut to the mate command. I assigned 'M' to the mate command. Once I select two surfaces I just hit 'M', then use a right click to confirm the coincident or concentric mate works (since SW always seems to guess correctly), then hit enter to finish up the mate command. No need for fancy, non standard macros.
My favorite macro, and the only one I really use, is one that toggles between selecting hidden lines and not. During normal use I have this one turned off. When I need to mate to an internal edge or make a line in an in context sketch line up with an existing feature I switch to wireframe mode and toggle this macro. I kludged this one together from other peoples work, but the final product is better than the sum of its parts. Instead of having one macro to turn the option on and another to turn it off this macro toggles between the two states. It also lets you know whats going on by giving feedback in the system tray.
Feast your eyes on it here: http://uberthin.com/hosted/solidworks/hidden_li...
Is it just me or does this post seem a little dated? The use of macros for mating has become obsolete with the addition of quick mates. With the macro you either have to have the two objects selected prerun or code the macro to ask for the user input. With quick mates you just hold down the ALT key and drag the first object over to the second one and then click OK. May be a few more operations from the user, but beats having to see an error box each time you forget to preselect.
Here's what I want: a macro to fully define a fastener to a hole. Mate references are nice and all, but a simple mate macro should be much quicker. Here's the idea:
-Select the top edge of the hole and an edge of the underside of the fastener (ie: the annulus)
-Run the macro, which assigns a concentric, coincident, and parallel mate, fully defining the fastener.
Now THAT would be tremendously useful. I'd write it myself, but I'm up to my eyeballs in paperwork right now. =/
Quickmates!?! HOW DID I NOT KNOW ABOUT THIS!?!?! BRILLIANT!!! You're my hero Jeff.
Since I read this post yesterday, I have now been adding macros for the mates. I found a set that had just about all the mates. I have been adding them to the macro toolbar and using some old AutoCAD 16 x 16 bitmaps from the object snaps to indicated the mate type. I knew those icons woudl be handy some day. Saves me time reinventing the wheel.
There would be no “easy” way to adjust the orientation of the mate, except going into the mate, right? So, maybe mention to align the objects close to what orientation you'd want. Would like distance mates, and possibly multiple coincident/concentric. Will have to look at these to see if possible to make them. Thanks!
Once you create the mate, you can RMB on the mate in the feature tree. This will give you some options on the mate depending upon the type. One of the options is to “Flip Mate Alignment”. A distance mate will add a “Flip Dimenison” option.
Yep Jeff, it's dated. I wish there was no need for macros actually. I'm all for the program knowing what I need to do and doing it, but those dang macros come in handy sometimes. This is one instance where I could show the usefulness of macros and open up ideas about using them for other functions that readers (like Rod) can use to make their job easier. It's kind of a two part post. Quickmates are great, but this show how to add commands, so to speak, and introduces people to very simple macro functionality. Cool?
Josh, Thanks for the post. Using the alt key to mate concident is fine when the two surfaces to be mated are not exactly parallel to each other. Yes, it can be done, but your macro has less keystrokes and more consistant results.
Thanks for the defense of my innocent macro tip
I can fly through assembly mates with'em. I hope this give some people ideas about speeding up the process/reducing keystrokes for other commands.
Rod – where might I find that set of macros?
Lenny's website is one: http://www.lennyworks.com/solidworks/
He has 2 sections listed on the left for macros
Also, Lorono's SW resources: http://sw.fcsuper.com/index.php?name=UpDownload
Matt Lombard's: http://mysite.verizon.net/mjlombard/macros.html
I believe I pulled mine from Matt Lombard's site. Enjoy!
good job. i am italian designer. good josh
I'm a new reader but been swxing for years. i cant seem to add configurations as a macro. i need to go over a large back catalogue and add colour configurations for each of many parts and then make a custom colour property so they get called up by colour into BOM. I can get solidworks scheduler to do the custom property bit but i need to manually create the configurations. Is there any way around this?
Justin, hi! good question! you can create a configuration with a macro. Record one to see how it works. Bring up the macro toolbar and start a new macro. go to the config tab and create a new macro. stop the macro and then edit it to see how solidworks creates it. This is a huge step in learning about automating solidworks. thanks!
Hey Josh,
Thanks for the assistance but i still dont seem to be able to do get it to work. Can you recommend somewhere i can learn more how macros work?
Try Lenny Kikstra's site: http://designsmarter.typepad.com/lennyworks/
Lenny is a SW god at this stuff
Is there a way to use a macro to change the configuration on a part inside an assembly?
Here is what the “record” writes, but when I run it, it doesnt work.
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
boolstatus = Part.Extension.SelectByID2(“part1@assem1″, “COMPONENT”, 0, 0, 0, False, 0, Nothing, 0)
Part.CompConfigProperties4 2, 0, True, “config1″, False
Part.ClearSelection2 True
boolstatus = Part.EditRebuild3
End Sub
you may have to have a prompt to select which part you want to change. I'm not an expert in the API, but you would have to have assemblies set up really similarly. For instance, I use a program that matches all the configurations with the same name, so all the parts with a 'Simple' configuration appear in the 'Simple' configuration of the assembly.
Is there a way to import parts/sub assy's into an assy using a design table
You should add one additional arguement into this command:
Part.CompConfigProperties4 2, 0, True, “config1″, False
It should be:
Part.CompConfigProperties4 2, 0, True, True, “config1″, False
You should add one additional arguement into this command:
Part.CompConfigProperties4 2, 0, True, “config1″, False
It should be:
Part.CompConfigProperties4 2, 0, True, True, “config1″, False
Comments on this entry are closed.
{ 1 trackback }