This program/code will help to manage the all font in same size with one click in solidWorks drawing. you can make a command tool in drawing by this macro.
This program will cover-
- Dimension font size
- Section view font size
- Diameter text location - horizontal
- Note font size
- Size of detail font size
- Save file after done all changes
In this program, font size is 8. you can change it as per requirement.
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
'dimension font size
Dim myTextFormat As Object
Set myTextFormat = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDimensionTextFormat, swUserPreferenceOption_e.swDetailingDimension)
myTextFormat.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDimensionTextFormat, swUserPreferenceOption_e.swDetailingDimension, myTextFormat)
'section font size
Dim myTextFormat1 As Object
Set myTextFormat1 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionTextFormat, 0)
myTextFormat1.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionTextFormat, 0, myTextFormat1)
Set myTextFormat1 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelNameTextFormat, 0)
myTextFormat1.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelNameTextFormat, 0, myTextFormat)
Set myTextFormat1 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelLabelTextFormat, 0)
myTextFormat1.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelLabelTextFormat, 0, myTextFormat)
Set myTextFormat1 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelScaleTextFormat, 0)
myTextFormat1.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelScaleTextFormat, 0, myTextFormat)
Set myTextFormat1 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelDelimiterTextFormat, 0)
myTextFormat1.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionLabelDelimiterTextFormat, 0, myTextFormat)
Set myTextFormat1 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionView_RotationTextFormat, 0)
myTextFormat1.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingSectionView_RotationTextFormat, 0, myTextFormat)
'diameter text location
boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingDimensionTextAndLeaderStyle, swUserPreferenceOption_e.swDetailingDiameterDimension, swDisplayDimensionLeaderText_e.swBrokenLeaderHorizontalText)
boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingDimensionTextAndLeaderStyle, swUserPreferenceOption_e.swDetailingRadiusDimension, swDisplayDimensionLeaderText_e.swBrokenLeaderHorizontalText)
'note font size
Dim myTextFormat2 As Object
Set myTextFormat2 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingNoteTextFormat, 0)
myTextFormat2.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingNoteTextFormat, 0, myTextFormat2)
'SIZE OF DETAILS
Dim myTextFormat3 As Object
Set myTextFormat3 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailTextFormat, 0)
myTextFormat3.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailTextFormat, 0, myTextFormat)
Dim myTextFormat4 As Object
Set myTextFormat4 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_NameTextFormat, 0)
myTextFormat4.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_NameTextFormat, 0, myTextFormat)
Set myTextFormat4 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_LabelTextFormat, 0)
myTextFormat4.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_LabelTextFormat, 0, myTextFormat)
Set myTextFormat4 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_ScaleTextFormat, 0)
myTextFormat4.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_ScaleTextFormat, 0, myTextFormat)
Set myTextFormat4 = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_DelimiterTextFormat, 0)
myTextFormat4.CharHeightInPts = 8
boolstatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingDetailView_DelimiterTextFormat, 0, myTextFormat)
'save file
Dim swErrors As Long
Dim swWarnings As Long
boolstatus = Part.Save3(1, swErrors, swWarnings)
End Sub
Download Macro- Click Here