-
-
Re: Standard Planes on a Toolbar
Steve Calvert Aug 3, 2018 7:18 AM (in response to Alan Metcalfe)Alan Metcalfe I think he wants to be able to toggle on and off the main planes from a menu selection and the problem I see there is that most people, while modeling, turn off those planes when the file is ready for release or even if just checked in.
Steve C
-
-
Re: Standard Planes on a Toolbar
Glenn Schroeder Aug 3, 2018 7:56 AM (in response to Serge Piastra)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 Aug 3, 2018 8:09 AM (in response to Serge Piastra)Hello,
I believe you'll need a macro to add a toolbar, but this is beyond me.
Other options:
- Add them as mouse gestures
- Add them as keyboard shortcuts
- Modify an existing toolbar that you don't use and add them there (and remove the others if they bother you)
- Add a new tab to Command Manager (right click, Customize, click "New Tab") and add them here
- Add them to an existing Command Manager tab, such as Ref Geometry
Cheers,
Kevin
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 Aug 3, 2018 8:18 AM (in response to Serge Piastra)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.
Cheers,
Kevin
-
Re: Standard Planes on a Toolbar
Frank RueppAug 3, 2018 8:39 AM (in response to Serge Piastra)
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:
- Select the planes and add them to your favorites:
- 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:
- Now you can expand the Favorites in the upper section of the Feature Manager:
- 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:
- If you already know which mate you want to apply you can select a quick mate option:
- Or you can create a mate and the mate PM will open in the lower portion of the tree:
- 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.
- 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
Frank
SOLIDWORKS Product Defintion Team
- Select the planes and add them to your favorites:
-
Re: Standard Planes on a Toolbar
Josh Brady Aug 3, 2018 8:51 AM (in response to Serge Piastra)Serge,
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.
-
CycleRefFeatures.swp.zip 19.0 KB
-
Re: Standard Planes on a Toolbar
Serge Piastra Aug 5, 2018 8:24 PM (in response to Josh Brady)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 Aug 6, 2018 8:15 AM (in response to Serge Piastra)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 Aug 6, 2018 9:26 AM (in response to Serge Piastra)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 Else 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 Else 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 Else 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)) Next 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 Loop '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
Serge Piastra Aug 6, 2018 6:02 PM (in response to Josh Brady)Thanks again Josh for your time & effort: very much appreciated.
I'll put my "VB for Dummies" cap on, and follow your instructions !
Kind regards from Down Under.
-
Re: Standard Planes on a Toolbar
Serge Piastra Aug 8, 2018 6:04 PM (in response to Josh Brady)Thanks Josh!!!! 'Works like a charm....
Cheers
-
-
-
-
Re: Standard Planes on a Toolbar
Jeremy Feist Aug 3, 2018 10:04 AM (in response to Serge Piastra)how about an existing button to toggle the visibility of your primary planes?
-
Re: Standard Planes on a Toolbar
Serge Piastra Aug 5, 2018 7:13 PM (in response to 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
Jeremy Feist Aug 6, 2018 9:26 AM (in response to Serge Piastra)Serge Piastra wrote:
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.
serge piastre, if "P" shows and hides your planes, that is something you have customized ("P" is not an out of the box keyboard shortcut). So first, good on you for customizing your interface. Second, I was referring to the NEW function to toggle the display of JUST the primary planes (which you can also assign to a keyboard shortcut, if you wanted). It does require you to have the general display of the planes set to visible, and works best when the individual planes are set to hidden.
-
Re: Standard Planes on a Toolbar
Serge Piastra Aug 6, 2018 6:10 PM (in response to Jeremy Feist)Hi Jeremy.
Yes, I tend to use keyboard shortcuts in SWX since my left hand is not very busy, most of the time I even have a small numerical keyboard to my left, used mainly for SAP.
We are running SWX Premium 2017 SP5.0 here and the new feature you mentioned must have been introduced in 2018. I'll make sure I will check this out when we finally upgrade.
Cheers
-
Re: Standard Planes on a Toolbar
Jeremy Feist Aug 6, 2018 6:42 PM (in response to Serge Piastra)I'm glad Josh Brady's macro works for you. but FYI the hide show primary planes was added in 2016
2016 What's New in SOLIDWORKS - Hiding and Showing Primary Planes
-
Re: Standard Planes on a Toolbar
Serge Piastra Aug 6, 2018 7:16 PM (in response to Jeremy Feist)Hi Jeremy,
Yes, that works fine in a part file, but in an assembly, all the planes become visible (unless their visibility was turned off). This can get a bit messy in a large ass'y and selecting the primary planes is still tricky when zoomed-in in a particular area.
Cheers
-
-
-
-
-
-
Re: Standard Planes on a Toolbar
Alexey Groutso Aug 6, 2018 7:04 PM (in response to Serge Piastra)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
Serge Piastra Aug 6, 2018 7:18 PM (in response to Alexey Groutso)Thanks for your suggestion Alexey.
I'll use Josh's macro for the time being. Works like a charm!
Cheers
-
Re: Standard Planes on a Toolbar
Glenn Schroeder Aug 7, 2018 8:01 AM (in response to Serge Piastra)Serge Piastra wrote:
Thanks for your suggestion Alexey.
I'll use Josh's macro for the time being. Works like a charm!
Cheers
Then don't you think you should unmark your reply to him as the correct answer, and mark his instead?
-
-
Re: Standard Planes on a Toolbar
Glenn Schroeder Aug 8, 2018 8:14 AM (in response to Serge Piastra)Serge Piastra wrote:
Hi Glen,
I thought I had marked Josh's post as "correct answer":
Not sure what I've done wrong here. Can you assist please?
Cheers
You marked your own Reply to Josh as the Correct answer. There's a link in your screenshot on your Reply that says "Unmark as Correct." Click on that, then you'll have the option to mark the Reply you got from Josh as the correct one.
-
Re: Standard Planes on a Toolbar
Serge Piastra Aug 8, 2018 6:03 PM (in response to Glenn Schroeder)Done! Thanks Glen.
Cheers
-
-
-
-
-
-
Re: Standard Planes on a Toolbar
M. D. Aug 8, 2018 6:24 PM (in response to Serge Piastra)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 Aug 8, 2018 7:25 PM (in response to M. D.)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.
-