11 Replies Latest reply on Aug 3, 2015 3:29 PM by Ed Cyganik

    simple macro

    Ed Cyganik

       

      What I'm trying to do is to create a macro that will do the following:

       

      Select the Mate Command

       

      Select Offset

       

      Input a distance of .0625

       

      ...then wait for user input.

       

      That's it! I would then be left to select two faces and select OK to complete the mate.

       

         I remember creating all kinds of simple macros like this in the past and it was a straight forward process, very easy to do. Now, I can't even get anything to run.

       

      Regards

       

      Ed Cyganik

       

        • Re: simple macro
          JOHN GEORGE

          There is a simple macro from Josh is available here

          Try this and see if that works

          • Re: simple macro
            Feroz Mahomed

            Ed,

             

            Attached is a macro that I use to mate to parts using a distance mate. You have to select the two faces first and then enter the distance in the pop up.

            • Re: simple macro
              Mark Olsen

              Ed,

                   This will open the feature manager, but I'm not sure how to select the distance mate nor how to enter the distance.

               

              Mark

               

              Dim swApp As SldWorks.SldWorks
              Sub main()

              Set swApp = Application.SldWorks

              swApp.RunCommand swCommands_Mate, "New Mate"

              End Sub

               

              BTW, make sure that the Solidworks commands type library reference is loaded.

                • Re: simple macro
                  Ed Cyganik

                  Thanks to everyone for their responses.

                  I ended up editing the macro from Feroz as follows:

                   

                  Dim swApp As Object

                  Sub main()

                  ' Prerequisite: Pre-Selection of two Surfaces

                  ' Automatic Mate Offset of .0625 (1.58mm)

                  Set swApp = CreateObject("SldWorks.Application")

                  Set Part = swApp.ActiveDoc

                  Part.AddMate 5, 2, 0, 1.58 / 1000, 0.5235987755983

                  Part.ForceRebuild3 (True)

                  Part.ClearSelection

                  End Sub

                   

                  This is all I needed, a simple mate offset of .0625 for the gap between two panels. This mate type is performed hundreds of time per week, so you can imagine the time savings over the course of a year, time 7 designers. I assigned the macro a keyboard shortcut so the process is lickety-split!

                   

                  Thanks again.

                    • Re: simple macro
                      Deepak Gupta

                      Ed, did you tried using mate references instead?

                        • Re: simple macro
                          Ed Cyganik


                          Hello Deepak,

                            Yes, I am using Mate References as defined in our templates for sheet metal panels. The problem is both sides of a panel cannot be defined with the mate reference name, see image.

                            Do you know a trick for them?

                            • Re: simple macro
                              Deepak Gupta

                              Ed, I've not tried this but how about a mid plane and then set distance mate reference on that.

                                • Re: simple macro
                                  Ed Cyganik

                                  Deepak,

                                   

                                     I did think about that but Mate References do not have an option for "offset".

                                   

                                  Mate References is yet another example of functionality without capability. This is something SolidWorks is famous for and one of the reasons you have not seen me around here like I used to be. Solidworks loves to introduce new tools but in many cases, they are "half-baked".

                                   

                                  Sorry for ranting, thanks for suggestions.

                                   

                                  Eddie

                                  _______

                                  /l ,[____],

                                  l---L -OlllllllO-

                                  ()_) ()_)--o-)_)

                                    • Re: simple macro
                                      Deepak Gupta

                                      Oh, sorry I meant to say that set a plane offset from the surface and add mate references to that. But I'm not sure how this would react in assembly.

                                       

                                      But wait, you can actually use the planes to make the macro work faster. Make two planes in the part and you may name them (make sure they have same name in desired parts). Now in the macro you can set the codes to select the planes and add mates to them. This would avoid selecting the two faces.

                                        • Re: simple macro
                                          Ed Cyganik

                                          Sorry for the late reply Deepak,

                                           

                                             The panels are essentially the same, they are made from the same template, so the same mate reference cannot be applied to both side.

                                           

                                          I believe I've done the best I can by using mate refernces for two mates and a macro to apply a third.

                                           

                                          Thanks again,

                                           

                                          Eddie