DISQUS

DISQUS Hello! SolidSmack is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

SolidSmack

SolidWorks 3D CAD Technology Design Blog
Jump to original thread »
Author

Two SolidWorks Macros For Blazin’ Fast Assembly Work

Started by Josh M · 9 months ago

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’ ... Continue reading »

23 comments

  • 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!
  • 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.
  • good job. i am italian designer. good josh
  • 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.
  • 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.
  • 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?
  • Quickmates!?! HOW DID I NOT KNOW ABOUT THIS!?!?! BRILLIANT!!! You're my hero Jeff.
  • 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. =/
  • 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...
  • Josh, you are slowly forcing me to become more efficient. I enjoy that.

    There have been some days when my monitor almost looked like the one in the post.
  • 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!
  • 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.
  • 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!
  • 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.
  • 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
  • Is there a way to import parts/sub assy's into an assy using a design table

Add New Comment

Returning? Login