Page 1 of 1

Axis lines when creating a new sketch

Posted: Tue Feb 06, 2024 12:03 pm
by Ben_mtl
Hello,
First, sorry for my English, not my 1st language.. doing my best.
I tried to find an answer to what I'm looking for but can't find anything.

So I'm kinda new to Solidworks, have been a long time Catia user but my new job uses Solidworks, I love it !
One thing I miss is how to have X and Y axis directly when I create a new sketch. Of course the origin is always there but 99% of the time I start by creating 2 axis in my new sketch. Then I take care of the dimensions from those 2 construction lines.

Is there any way to have those 2 lines already there when I create a new sketch ?

I attached a picture of what I'm looking for...
Thanks for any help !

Re: Axis lines when creating a new sketch

Posted: Tue Feb 06, 2024 2:19 pm
by Arthur NY
You have two options....

Option 1: Create a sketch with the two lines in it and save it as a Library file. This sketch can then be dragged into any new Part file and you're off to the races. Keep in mind that you can bring it in and leave it referencing the original or can break the link so that way it's not looking at the original sketch.

Option 2: Create the sketch and then do "File, Save As" and then change it to a "Part Template". This will then make it so that when you open anew Part file and use that template the sketch will always be there.

The second method might be preferred... and just know that just about anything can be saved into a Part, Assembly, or Drawing template.

Re: Axis lines when creating a new sketch

Posted: Tue Feb 06, 2024 2:48 pm
by DLZ_SWX_User
Arthur NY wrote: Tue Feb 06, 2024 2:19 pm Option 2: Create the sketch and then do "File, Save As" and then change it to a "Part Template". This will then make it so that when you open anew Part file and use that template the sketch will always be there.
This is what I'd probably do. Though I have not tried it out to see how it would work with sketch I have used it to have my new part template open with some options turned off or on based on what I what to design.

Re: Axis lines when creating a new sketch

Posted: Tue Feb 06, 2024 3:58 pm
by SPerman
My template has axes in it. I also have a macro to add them to any part/assembly file. These are not sketch axis, but the 3 primary axis that can be used on any sketch/feature. You will likely have to make some changes to the macro, as it relies on the names of the planes being consistent.
image.png
image.png (20.56 KiB) Viewed 1578 times
AddAxis.swp
(64.5 KiB) Downloaded 85 times

Re: Axis lines when creating a new sketch

Posted: Tue Feb 06, 2024 4:15 pm
by AlexLachance
Hey fellow frenchie!

There's a few ways you could get what you desire but I think it would be best to know how you use these. Sorry, I've never used Catia :P

The origin could be displayed also, but that would not necessarly give you the 3 axises you desire.

Re: Axis lines when creating a new sketch

Posted: Tue Feb 06, 2024 7:59 pm
by Uncle_Hairball
SPerman wrote: Tue Feb 06, 2024 3:58 pm My template has axes in it. I also have a macro to add them to any part/assembly file. These are not sketch axis, but the 3 primary axis that can be used on any sketch/feature. You will likely have to make some changes to the macro, as it relies on the names of the planes being consistent.

image.png

AddAxis.swp
Thanks for the helpful macro. Since I do approximately zero programming, I have a beginner-level question, if you don't mind. Can you tell me how to modify the macro to check for existing axes? The reason I need to do this is that some of our company templates have one axis and others have three, but none have no axes.

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 8:46 am
by Glenn Schroeder
SPerman wrote: Tue Feb 06, 2024 3:58 pm My template has axes in it. I also have a macro to add them to any part/assembly file. These are not sketch axis, but the 3 primary axis that can be used on any sketch/feature. You will likely have to make some changes to the macro, as it relies on the names of the planes being consistent.

image.png

AddAxis.swp
I had the three primary axes in my Assembly template for years, but I only used them for Linear Patterns, so when the enhancement was added allowing us to use planes instead I deleted them.

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 9:22 am
by Ben_mtl
Thanks a lot for those suggestions. I looked at them and the solution was super easy : a macro !

So I selected a plane first, then started recording what I wanted to do : clic "sketch button", create 2 lines (vertical + horizontal), job's done !

Created a "new" icon to use the macro just beside the usual sketch button.
Capture d’écran 2024-02-07 102449.jpg
Capture d’écran 2024-02-07 102449.jpg (10.33 KiB) Viewed 1467 times
When you click the button the macro starts.

And you end up in the exact situation as my picture in the first post : sketch mode in the selected plane (or surface), 2 lines already drawn, it's your turn to take the mouse !
Capture d’écran 2024-01-31 121328.jpg


Here is the code:
Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateCenterLine(0#, 0.04014, 0#, 0#, 0#, 0#)
Set skSegment = Part.SketchManager.CreateCenterLine(0#, 0#, 0#, 0.038859, 0#, 0#)
Part.SetPickMode
Part.ClearSelection2 True
End Sub


I have to see how I can modify the code so it also works if I have no surface/plane selected when clicking the button (the script would asks me for a plane/surface before "clicking" the sketch button), but I'm already super happy with that.

Thanks again !

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 10:22 am
by Dwight
Try making the 3 main planes show (not hidden) and dimension to those. That will work in most situations for what you want to do. I try to dimension to main planes in sketches whenever possible. You can always hide the main planes later, if you don't want them to show in the model.

I do leave the main planes hidden all the time, but select them in the tree when I dimension to them.

Dwight

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 10:34 am
by SPerman
Glenn Schroeder wrote: Wed Feb 07, 2024 8:46 am I had the three primary axes in my Assembly template for years, but I only used them for Linear Patterns, so when the enhancement was added allowing us to use planes instead I deleted them.
I use them on every part I draw, but I come from NX where coordinate systems were real and powerful tools. Axis are as much a part of my modeling as planes are.

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 11:33 am
by DanPihlaja
You cold just add a coordinate system to your template. It works just as well and is 1 item.

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 1:05 pm
by SPerman
That may be true in 2024, but in 2017, when I started, coordinate systems were all but useless. I had one in my template, before I figured out I couldn't use it's planes or axes.

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 2:27 pm
by DanPihlaja
SPerman wrote: Wed Feb 07, 2024 1:05 pm That may be true in 2024, but in 2017, when I started, coordinate systems were all but useless. I had one in my template, before I figured out I couldn't use it's planes or axes.
Yes that's true. It needs to be SW 2022 or later.

Re: Axis lines when creating a new sketch

Posted: Wed Feb 07, 2024 3:08 pm
by SPerman
Even in 2022, the CS isn't as useful as it could be. There is no way to select the planes or axes via the history tree.