G'Day
I use a macro to insert a new custom size sheet in a Solidworks 2019 drawing. (I have created a custom template "TAG_MW_Single_View".) The macro work well and it sets all properties as required. The only thing missing is to deselect "Display sheet format". I have recorded macro when I do it manually and the code for that is:
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.ClearSelection2 True
boolstatus = Part.SetupSheet5("MW Sheet", 12, 12, 1, 20, False, "C:\SWDVault\Engineering\Z00 -
Solidworks\sheetformat\TAG_MW_Single_View.slddrt", 0.42, 0.297, "Default", False)
End Sub
The "Part.ClearSelection2 True" is the code that clears the box, but if I use it in my code it does not work.
I have also tried "swDraw.SheetFormatVisible = False" and that use to work but for some reason it is not working anymore. I must have changed some code somewhere else.
Regards
Jaco
How to unselect "Display sheet Format" in VBA
-
- Posts: 47
- Joined: Wed Mar 01, 2023 6:55 pm
- x 33
- x 4
How to unselect "Display sheet Format" in VBA
You need to get the current sheet, and then turn off the sheet format visibility.
Try
Go to full postTry
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim currentsheet As Sheet
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
boolstatus = Part.SetupSheet5("MW Sheet", 12, 12, 1, 20, False, "C:\SWDVault\Engineering\Z00 - Solidworks\sheetformat\TAG_MW_Single_View.slddrt", 0.42, 0.297, "Default", False)
Set currentsheet = swModel.GetCurrentSheet
currentsheet.SheetFormatVisible = False
End Sub
Re: How to unselect "Display sheet Format" in VBA
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
-
- Posts: 47
- Joined: Wed Mar 01, 2023 6:55 pm
- x 33
- x 4
Re: How to unselect "Display sheet Format" in VBA
#SPerman - I have tried it before and it use to work, but for some reason it is not working now. This is my code:
Code: Select all
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As Sheet
Dim SelMan As SldWorks.SelectionMgr
Dim retval As Boolean
Dim vSheetProps As Variant
Dim TemplateName As String
Dim instance As ISheet
Sub main()
TemplateName = "C:\SWDVault\Engineering\Z00 - Solidworks\sheetformat\TAG_MW_Single_View.slddrt"
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
'swApp.SendMsgToUser "Complete"
retval = swDraw.NewSheet3("MW Sheet", swDwgPapersUserDefined, swDwgTemplateCustom, 1, 20, False, TemplateName , 0.08, 0.08, "MW View") ' TAG_MW_Single_View.slddrt
swDraw.ActivateSheet ("MW Sheet")
' Get the drawing document
' Get the active document
Set swModel = swApp.ActiveDoc
' swDraw.SheetFormatVisible = False
instance.SheetFormatVisible = False
.......more code
-
- Posts: 47
- Joined: Wed Mar 01, 2023 6:55 pm
- x 33
- x 4
Re: How to unselect "Display sheet Format" in VBA
In a similar case, how do I set "Display all configuration of the same part as one item" as "Part configuration Grouping" with VBA code?
-
- Posts: 47
- Joined: Wed Mar 01, 2023 6:55 pm
- x 33
- x 4
Re: How to unselect "Display sheet Format" in VBA
Hi @RonE
Do you have some wisdom about this issue? It should be very similar to the problem you solved earlier - I am just not skilled enough to connect the dots.
Regards
Jaco
Do you have some wisdom about this issue? It should be very similar to the problem you solved earlier - I am just not skilled enough to connect the dots.
Regards
Jaco
Re: How to unselect "Display sheet Format" in VBA
You need to get the current sheet, and then turn off the sheet format visibility.
Try
Try
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim currentsheet As Sheet
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
boolstatus = Part.SetupSheet5("MW Sheet", 12, 12, 1, 20, False, "C:\SWDVault\Engineering\Z00 - Solidworks\sheetformat\TAG_MW_Single_View.slddrt", 0.42, 0.297, "Default", False)
Set currentsheet = swModel.GetCurrentSheet
currentsheet.SheetFormatVisible = False
End Sub
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
-
- Posts: 47
- Joined: Wed Mar 01, 2023 6:55 pm
- x 33
- x 4
Re: How to unselect "Display sheet Format" in VBA
Thanks @gupta9665 . It is now working fine.