This website uses cookies to ensure you get the best experience on our website. By using our website you agree on the following Cookie Policy, Privacy Policy, and Terms Of Use
This VBA macro changes the tesselation settings of Shaded and draft quality HLR/HLV resolution and Wireframe and high quality HLT/HLV resolution settings in the SOLIDWORKS documents
This allows to change the quality of tesselation which affects the perfromance and size of the file. Lower quality improves the performance and decreases the file size, file higher quality reduces the performance and increases the file size.
Macro can be configured by specifying the percentage of the position of the slider
Const SHADED_DRAFT_QUALITY_RESOLUTION AsDouble = 0.25 '0 for minumum, 1 for maximum, 0.5 for the middle positionConst WIREFRAME_HIGHT_QUALITY_RESOLUTION AsDouble = 0.25 '0 for minumum, 1 for maximum, 0.5 for the middle position
Const SHADED_DRAFT_QUALITY_RESOLUTION AsDouble = 0.5 '0 to 1Const WIREFRAME_HIGHT_QUALITY_RESOLUTION AsDouble = 0.5 '0 to 1Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swModel = swApp.ActiveDoc
Const QUALITY_MIN AsInteger = 0
Const QUALITY_MAX AsInteger = 106
Dim qualVal AsInteger
qualVal = CInt(QUALITY_MIN + (QUALITY_MAX - QUALITY_MIN) * SHADED_DRAFT_QUALITY_RESOLUTION)
swModel.SetTessellationQuality qualVal
Const WIREFRAME_HIGHT_QUALITY_RESOLUTION_MIN AsInteger = 1
Const WIREFRAME_HIGHT_QUALITY_RESOLUTION_MAX AsInteger = 100
Dim wireframeResVal AsInteger
wireframeResVal = CInt(WIREFRAME_HIGHT_QUALITY_RESOLUTION_MIN + (WIREFRAME_HIGHT_QUALITY_RESOLUTION_MAX - WIREFRAME_HIGHT_QUALITY_RESOLUTION_MIN) * WIREFRAME_HIGHT_QUALITY_RESOLUTION)
IfFalse = swModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swImageQualityWireframeValue, swUserPreferenceOption_e.swDetailingNoOptionSpecified, wireframeResVal) Then
Err.Raise vbError, "", "Failed to set the image quality wireframe resolution"EndIf
swModel.SetSaveFlag
EndSub
Notifications
Join session by SOLIDWORKS and PDM API expert Artem Taturevych at 3DEXPERIENCE World 2026 on Wednesday, Feb 4 at 08:30 AM CST to explore 10 essential macros for automating drawings, assemblies, custom properties, and more