Code: Select all
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim BoolStatus As Boolean
Dim SystemOfUnits As Integer
Dim DualSystemOfUnits As Integer
Dim PrimaryLengthDecPlaces As Integer
Dim AngularUnits As Integer
Dim MassDecPlaces As Integer
Dim DualLengthDecPlaces As Integer
Dim AngularDecPlaces As Integer
Dim DecimalRoundingMethod As Integer
Dim TimeDecPlaces As Integer
SystemOfUnits = swUnitSystem_e.swUnitSystem_IPS
DualSystemOfUnits = swMM
PrimaryLengthDecPlaces = 3
DualLengthDecPlaces = 1
AngularUnits = swDEGREES
AngularDecPlaces = 0
MassDecPlaces = 3
DecimalRoundingMethod = swUnitsDecimalRounding_e.swUnitsDecimalRounding_HalfAway
TimeDecPlaces = 2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
swApp.SendMsgToUser2 "No drawing document open.", swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOkCancel
Exit Sub
End If
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitSystem, 0, SystemOfUnits)
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsDualLinear, 0, DualSystemOfUnits)
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, 0, PrimaryLengthDecPlaces)
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsDualLinearDecimalPlaces, 0, DualLengthDecPlaces)
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsAngular, 0, AngularUnits)
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsAngularDecimalPlaces, 0, AngularDecPlaces)
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropDecimalPlaces, 0, MassDecPlaces)
BoolStatus = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsDecimalRounding, 0, DecimalRoundingMethod)
End Sub