27 Replies Latest reply on Aug 8, 2018 7:25 PM by Alexey Groutso

    Standard Planes on a Toolbar

    Serge Piastra

      Is it possible to create a Customised Toolbar which would give the user access to the Standard Planes (Front, Top & Right), the planes which are located at the top of the Feature Manager?

      In an assembly, let say I need to assign a parallel mate between the Top plane of a part and the Top plane of the assembly.
      In a large assembly with many parts, the feature Manager can be quite "tall" and when selecting the Top plane of the part, one has to scroll right up to the top of the tree in order to select the Top plane of the assembly.

      The toolbar would just look like the attached picture (In a landscape orientation though...).


      Having a "floating" toolbar with the 3 standard planes of the assembly (and perhaps also the Origin) would save time.

      Thanks for any feedback & regards to all!

        • Re: Standard Planes on a Toolbar
          Alan Metcalfe

          Hi Serge,

          The tool is already there when you are in the mate menu.

          If you select the arrow where highlighted below it expands to a tree and the standard Planes can be selected.


          • Re: Standard Planes on a Toolbar
            Glenn Schroeder

            I'm pretty sure there isn't a way to have them in a toolbar.  Have you considered just making them visible so you can select them in the graphics area?

            • Re: Standard Planes on a Toolbar
              Kevin Chandler



              I believe you'll need a macro to add a toolbar, but this is beyond me.


              Other options:

              1. Add them as mouse gestures
              2. Add them as keyboard shortcuts
              3. Modify an existing toolbar that you don't use and add them there (and remove the others if they bother you)
              4. Add a new tab to Command Manager (right click, Customize, click "New Tab") and add them here
              5. Add them to an existing Command Manager tab, such as Ref Geometry






              EDIT: You may already know this, but with the cursor hovering over Command Manager, rolling the mouse wheel scrolls CM.

              • Re: Standard Planes on a Toolbar
                Kevin Chandler

                Hello again,


                A more lucid post this time (we hope).


                Record six macros: one each for showing or hiding each plane.

                Assign each macro to a button (this is doable and by searching the forum you should find the how-to).

                Place the buttons using one of the options I scratched out above.


                To reduce the buttons to 3, you'll need to modify each plane's code to query & toggle the current state.

                I'm sure others here can assist you with this, if needed.


                Same thing for the origin.


                Unlike the changing icons in the tree, I don't believe your button's display won't reflect the show/hide state w/o additional coding.





                • Re: Standard Planes on a Toolbar
                  Frank Ruepp

                  Hi Serge,


                  you could add the main assembly reference planes to your favorites so that they would appear at the very top of your assembly tree and then split the Feature Manager:

                  1. Select the planes and add them to your favorites:
                  2. Then move to the very top of the Feature Manager and you will notice that your cursor changes and that you can split the Feature Manager:
                  3. Now you can expand the Favorites in the upper section of the Feature Manager:
                  4. In the bottom portion of the FM you can expand the tree and then you can select the ref plane in the upper section of the FM:
                  5. If you already know which mate you want to apply you can select a quick mate option:
                  6. Or you can create a mate and the mate PM will open in the lower portion of the tree:
                  7. The only flaw in this workflow is that the upper portion gets automatically resized as long as the mate dialog is up (see screenshot above).  So you would have to either close the mate dialog after you have applied the mate or you would have to resize the top portion so that it shows all your favorites again.
                  8. When you double click on the separator line the split FM will disapear and you are back to your "ordinary" FM.


                  This is just a workaround and I am not sure if it works in all cases but perhaps it is a small bandaid that takes you a little bit closer to what you actually envision.


                  Hope this helps

                  Kind regards


                  SOLIDWORKS Product Defintion Team

                  • Re: Standard Planes on a Toolbar
                    Josh Brady


                    Please try the attached macro.  It works best when you map it to a shortcut key (I use "R" for Reference geometry), but you can put it on a toolbar as well.


                    When you have an assembly open, if nothing is currently selected, it will select the front plane of the assembly.  Run it again and it will select the Top plane.  Once more, the Right plane, then the origin. After the origin it cycles back to the Front plane.


                    If you have any part of a component selected when you run the macro, it will select the planes of the component.


                    This macro only affects the last selection.  So, for example, if you want to mate the top plane of a new part to the right plane of the assembly, you would (with nothing selected) run the macro 3 times (Assembly's plane selected), then ctrl-select any portion of the part (face, edge, select component in the tree, doesn't matter) and run the macro 2 times.


                    As I mentioned, this works best when you map to a shortcut key.  The macro is very fast, so running it multiple times in a row is quick.  Because it's a shortcut key, you never move your mouse away from the working area, and because the planes etc. highlight directly in the graphics area you never have to move your eyes away from what you're working on.

                      • Re: Standard Planes on a Toolbar
                        Serge Piastra

                        Josh: thanks again for taking the time to write a macro.

                        Is there any chance the macro could be "cut short" and stop when the plane is selected by the macro? I would then make 3 copies of the macro, edit the code to select either the  Front, Top or Right plane and create a button for ea. macro + a toolbar.

                        I made a copy of your macro and to cut "bits" out of it just to try.... Of course, not knowing what I was doing, I made a mess of it!!!! Dummies like me should be allowed to touch VB 

                          • Re: Standard Planes on a Toolbar
                            Josh Brady

                            Hey Serge,

                            That functionality is already built in...


                            Check out the stuff way up at the top of the code:


                            Const STOPATORIGIN As Boolean = False
                            Const FIRSTREF As Long = 1
                            'Change the value of FIRSTREF above if you want
                            'one of the primary planes to be the first feature
                            'selected by the macro.  Values are:
                                'Front  = 1
                                'Top    = 2
                                'Right  = 3
                                'Origin = 4
                            • Re: Standard Planes on a Toolbar
                              Josh Brady

                              Here's a modification... in the previous macro, changing that constant only changes which geometry gets selected first.  If reference geometry is already selected, it will still cycle through the features as before rather than going directly to the one specified by FIRSTREF.


                              Here's one that will only select the geometry specified.  It's one macro with four methods.  When you assign the macro to a button, you need to select the starting method (SelFront, SelTop, etc).  You can make four different buttons, each with a different method.  They'll all call the same selection code, they just pick different geometry.  You don't need to make four copies of the macro, just four buttons.  Or 3 if you just want the planes.  Or however many buttons you want.



                              ' Macro to select main reference geometry of an assembly component
                              ' for easy mating.  Modified extensively from the
                              ' "Select Origin of Assembly Component Example (VB)" in
                              ' SolidWorks and Add-Ins API Help
                              ' Preconditions:
                              '       (1) Assembly document is open.
                              ' Postconditions: One of the reference planes or the
                              ' origin of the last selected component is selected.
                              ' Or, if nothing was selected, reference geometry of the
                              ' top level assembly.
                              ' Change the constant below to specify which piece of ref geometry to select
                              Option Explicit
                              Sub SelFront()
                                  makeSel 1
                              End Sub
                              Sub SelTop()
                                  makeSel 2
                              End Sub
                              Sub SelRight()
                                  makeSel 3
                              End Sub
                              Sub SelOrigin()
                                  makeSel 4
                              End Sub
                              Sub makeSel(FirstRef As Long)
                                  Dim swApp                       As SldWorks.SldWorks
                                  Dim swModel                     As SldWorks.ModelDoc2
                                  Dim swSelMgr                    As SldWorks.SelectionMgr
                                  Dim swSelComp                   As SldWorks.Component2
                                  Dim swCompModel                 As SldWorks.ModelDoc2
                                  Dim swFeat                      As SldWorks.Feature
                                  Dim bRet                        As Boolean
                                  Dim GeneralSelObj               As Object
                                  Dim myFeatureCollection         As New Collection
                                  Dim i                           As Integer
                                  Dim CurSelCount                 As Long
                                  Dim MyTempPointObj              As Object
                                  Dim mySelStr                    As String
                                  Dim NewObjToSelect              As Object
                                  Dim Chunks                      As Variant
                                  Dim swVer                       As Variant
                                  Dim ResolveIt                   As Integer
                                  Dim DocTitle                    As String
                                  Set swApp = Application.SldWorks
                                  Set swModel = swApp.ActiveDoc
                                  If swModel.GetType <> swDocASSEMBLY Then
                                      MsgBox "This macro works on assembly documents only."
                                      Exit Sub
                                  End If
                                  'This next block of code just gets the component for whatever was las selected (if one is selected)
                                  'and checks to see if it's suppressed, or if it's lightweight in SW<2006
                                  Set swSelMgr = swModel.SelectionManager
                                  CurSelCount = swSelMgr.GetSelectedObjectCount
                                  If CurSelCount <> 0 Then
                                      Set GeneralSelObj = swSelMgr.GetSelectedObject(CurSelCount)
                                      Set swSelComp = swSelMgr.GetSelectedObjectsComponent(CurSelCount)
                                      If Not swSelComp Is Nothing Then
                                          If swSelComp.GetSuppression = swComponentSuppressed Then
                                              MsgBox "Can't get to reference geometry of a suppressed component."
                                              Exit Sub
                                          End If
                                      End If
                                      swVer = Split(swApp.RevisionNumber, ".")
                                      If CInt(swVer(0)) < 14 Then
                                          If swSelComp.GetSuppression <> swComponentFullyResolved Then
                                              If swSelComp.GetSuppression <> swComponentResolved Then
                                                  ResolveIt = MsgBox("The component selected is not fully resolved." _
                                                     & vbCrLf & "This functionality is only available for lightweight" & vbCrLf & _
                                                     "components in SolidWorks 2006 or greater." & vbCrLf & vbCrLf & _
                                                     "Resolve this component now?", vbYesNo, "Upgrade Time!")
                                                  If vbYes = ResolveIt Then
                                                      swSelComp.SetSuppression2 swComponentFullyResolved
                                                      Exit Sub
                                                  End If
                                              End If
                                          End If
                                      End If
                                      swSelMgr.DeSelect CurSelCount
                                  End If
                                  'If swSelComp is nothing, that means nothing was selected when the macro was run, therefore we
                                  'need to get the geometry of the top level assembly.  Then we get the first feature of
                                  'either top level or the selected component for iteration.
                                  If swSelComp Is Nothing Then
                                      Set swSelComp = swModel.ConfigurationManager.ActiveConfiguration.GetRootComponent3(False)
                                      Set swFeat = swModel.FirstFeature
                                      Set swFeat = swSelComp.FirstFeature
                                  End If
                                  'Now we iterate through the features of the component.  If the feature is a plane,
                                  'and it's not suppressed, we add it to a Collection.  Not selecting anything now,
                                  'just reading the feature tree.
                                  Do While Not swFeat Is Nothing
                                      If ("RefPlane" = swFeat.GetTypeName) And (False = swFeat.IsSuppressed) Then
                                           myFeatureCollection.Add swFeat
                                      End If
                                      'This sort of messy "If" block is what we have to do in order to select the origin in an
                                      'appropriate way for mating.  It's just added to the collection.
                                      If "OriginProfileFeature" = swFeat.GetTypeName Then
                                          Chunks = Split(swSelComp.Name2, "/")
                                          If StrComp(Right(swModel.GetTitle, 7), ".sldasm", vbTextCompare) <> 0 Then
                                              DocTitle = swModel.GetTitle
                                              DocTitle = Left(swModel.GetTitle, Len(swModel.GetTitle) - 7)
                                          End If
                                          mySelStr = "Point1@Origin@" & Chunks(0) & "@" & DocTitle
                                          For i = 0 To (UBound(Chunks) - 1)
                                              mySelStr = mySelStr & "/" & Chunks(i + 1) & "@" & Left(Chunks(i), (InStrRev(Chunks(i), "-") - 1))
                                          swModel.Extension.SelectByID2 mySelStr, "EXTSKETCHPOINT", _
                                              0, 0, 0, True, 0, Nothing, swSelectOptionDefault
                                          myFeatureCollection.Add swSelMgr.GetSelectedObject(swSelMgr.GetSelectedObjectCount)
                                          swModel.Extension.SelectByID2 mySelStr, "EXTSKETCHPOINT", _
                                              0, 0, 0, True, 0, Nothing, swSelectOptionDefault
                                          'This was the origin, which is assumed to always follow the 3 standard planes. Stop traversing the tree.
                                          Exit Do
                                      End If
                                      Set swFeat = swFeat.GetNextFeature
                                  'At this point (assuming that STOPATORIGIN was left as "true"), we should have a
                                  'Collection containing 4 items: the three main planes and the origin.
                                  'Now we just CHOOSE the one that we PLAN to select.  Just to avoid weird errors in case the
                                  'collection didn't get loaded right,
                                  'we choose Item #1 to start, but then we go ahead and try to choose the one we wanted
                                  'per the constant up at the top of the code.  If that "choosing" fails, #1 remains "chosen"
                                  If NewObjToSelect Is Nothing Then
                                      Set NewObjToSelect = myFeatureCollection.Item(1)
                                      On Error Resume Next
                                      Set NewObjToSelect = myFeatureCollection.Item(FirstRef)
                                      On Error GoTo 0
                                  End If
                                  'This is the line that actually selects the item we chose from the collection.
                                  bRet = NewObjToSelect.Select(True): Debug.Assert bRet
                              End Sub
                          • Re: Standard Planes on a Toolbar
                            Jeremy Feist

                            how about an existing button to toggle the visibility of your primary planes?

                            2018 SOLIDWORKS Help - Hiding or Showing Planes

                            • Re: Standard Planes on a Toolbar
                              Serge Piastra

                              First, a big thank you to all for taking the time to answer. Very much appreciated.

                              Second, some apologies. Due to the time difference and since I wrote my post on the eve of the week end, I only see all your replies now, coming back to work Monday morning - hence my lack of response to your suggestions.

                              I will try to answer, as best as I can:


                              Alan Metcalfe: Yes, I am aware of this, however it mean selecting the arrow, expand the tree and select the plane. I use this sometimes to add parts to an array for instance, but it can be tricky to select something out of the expanded tree is the background is "busy". And I was looking for something "quicker" such as clicking on an icon on a toolbar.


                              Steve, Glenn & Jeremy: I am also aware that planes can be toggled on or off by pressing "P". But SWX displays not only the standard planes, but any planes of the parts which make up the assembly (if their visibility is turned on). This can get messy (Just like turning on Temporary Axis!) and difficult to select in a very large assembly, and one may have to zoom out in order to see the primary planes.


                              Kevin: "rolling the mouse wheel scrolls CM": No, I wasn't aware of this. Thanks: handy trick to know.

                              Re. the macro, I would try this as a last resort The few brain cells I have left have a hard time with coding!


                              Frank: great suggestion. Looking for an answer to my onwn question, I had tried to add the planes in the Favorites, but didn't know what to do next.  I didn't realise (or forgot!) that you could split the FM...


                              Finally, thanks Josh for the macro; I will give it a try and let you know.

                              Once again, thanks to all for your time.

                              • Re: Standard Planes on a Toolbar
                                Alexey Groutso

                                At my work I work with skeleton assemblies on daily basis which means I have to deal with plane to plane, plane to sketch situations quite a bit. In fact these two types of mates will be 95% of my assembly mates.


                                In the past I had to constantly switch back to design tree to find the right plane but about two or three years ago I found that it was possible to disconnect your Property manager from the tab list. Since then my SolidWorks UI has my property manager sitting out on the left site of the screen



                                Right not it's actually sitting on another monitor, but it works even better on winder monitors where you aren't so restricted in horizontal space. There are some issues, one being That I would prefer it to sit on the right side of the design tree, I've been asking for this through Enhancement requests for some time now but with no results so far.


                                This also simplifies navigation through your model at part or assembly stage an. Especially when working with extrusions to vertices of other sketches or mating to skeleton model sketches.


                                Before anyone mentions that you can already do this by splitting design tree vertically. This doesn't work as well since most of the property manager menus take up most of the vertical space and constantly scrolling up and down through it is counterproductive.


                                This can sort of also be done with the fly-out design tree which shows up over the model space. Personally I can't stand it as I prefer to keep my model space clean so it is usually one of the 1st things I disable.


                                I would suggest you give this layout a go, works wonders when your model mates are focused on sketches planes and other features.

                                • Re: Standard Planes on a Toolbar
                                  M. D.

                                  Not a good answer to the OP, but I always mate faces.  The only reference geometry I have ever mated that I can recall is axes of parts.  Any specific situation where plane mates are crucial?  I suppose for a distance mate but I just offset from a surface.

                                    • Re: Standard Planes on a Toolbar
                                      Alexey Groutso

                                      Plane, axis, reference points and user cooridinates mates are extremely useful when your components tend to change quite often. In such cases it's very likely that faces that you have mated to would be moved or even deleted.


                                      However, if you know how your component is positioned based on it's origin, you can simply use primary planes to mate that component in your assembly. This way no matter how you modify this component it will always stay mated inside the assembly regardless of what geometry it has.


                                      This is a very typical case when working with skeleton driven models. Models where you have a "skeleton" component fixed in assembly which is specifically designed to drive geometry and location of most/all other components.