System option and document properties
Posted: Sat Feb 10, 2024 11:11 pm
I would like to understand a little better where and when Solidworks settings are used.
Solidworks pulls settings from a lot of locations depending on the user action.
I am focusing on CAD only, excluding PDM, simulation and edrawing from this discussion.
At the end of the day I prefere to have my company SW settings in a readable format, possibily plain text, or a REG file instead of relying on native files only. Native files are basically black boxes and it is difficult to make comparison at glance, having to dig all the settings screen in modelling assembly and drafting as you could miss some hidden option here and there.
This is why I am doing this kind of work, just to clean up all the garbage inside our data and keep track of what must be preserved from one CAD version to the next one.
---
My understanding is that SW system options are stored on a per windows user base inside the windows registry under
the "factory defaults" (sort of, since they seems to be missing some keys the user creates when using SW) are stored under
This is the simplest part and I am managing our company defaults pushing reg files to there.
But looking a bit closer to the above registry keys there are comprised by a lot of subkeys.
Depending on your installation there are over 15,000 unique settings including menus, toolbars, command manager, and other UI customizations. Splitting them in "System option" and "UI and other customizations" makes them more manageable.
Many System Option settings fall under this key and the below subkeys:
User interface is mostly (not all) under the "\user interface" subkeys.
There are some specialized subkeys like
but a lot of system options are just thrown under general together.
This is the simple part, and I think I got it.
What I do not understand is how other specialized keys are used by SW. Take:
This key contains what seems to belong to "document properties" not the "system options": arrow dimensions, center mark dimension, virtual sharps. When I remake my templates I need to import all those settings from our drafting standard file, so why are they there and when are they used? On what values are they setup? Are they a dump from a previously used template in case no template is selected in SW?
Dimension settings and other document related properties are saved inside the templates files, but roughly half of them can be saved to a drafting standards file.
So having to remake from scratch the templates for the second time, and considering the last time I missed a couple of options (out of 1500+) causing some annoyance in the company, this time I figured out to extract all the documents properties from our existing template using API and I was able to compare the new template (currently under remake) and the legacy one dumping all the settings in two txt files and comparing for differences.
Document settings are apparently divided by data type so you have settings divided in:
DOUBLE
INTEGER
STRING
TOGGLE
TEXT FORMAT(font objects and all their settings)
API Help have ALL the properties methods explained and for each of them the property enumeration (they are solidworks version dependend, sorted by name and there are "internal use only" and "obsolete" properties as well, so be careful when comparing apple with oranges...).
DOUBLE METHOD
https://help.solidworks.com/2022/Englis ... Redirect=1
DOUBLE ENUMERATORS (for the types below I will skip enumerators as they are linked in the method page)
https://help.solidworks.com/2022/Englis ... lue_e.html
INTEGER
https://help.solidworks.com/2022/Englis ... teger.html
STRING
https://help.solidworks.com/2022/Englis ... tring.html
TEXTFORMAT
https://help.solidworks.com/2022/Englis ... ormat.html
TOGGLE
https://help.solidworks.com/2022/Englis ... oggle.html
SAMPLE CODE BUTCHERED FROM API HELP JUST TO SHOW HOW TO GET PROPERTIES
I am working on a more comple macro with UI, but the concept is to dump all the properties and values inside a textbox then compare with notepad++ or winmerge the results from two different templates.
It took a while to figure out how this works, I think I understand SOME of the logic behind it, but I still have not figured it completely. For example your dimension line font in drawings is defined as both INTEGER (line font selection from a drop down menu in which the number is the selected item position) and a DOUBLE (the line font thickness value in meters).
This makes sense: integer value saves the UI configuration and the double value the real property value itself.
Apparently System option Settings and Document properties seems to be also mixed up in those categories and I ended up dumping all of them, often wondering if I am looking at the current document properties or my system settings. This is quite confusing.
The complete dump for most of the above properties (it excludes font settings like italic on/off etc) is already 1800 lines long. I think was able to compare the document properties of two templates made in SW2022 and SW2023, and I was able to find some mistake I made when I manually set one of our new template, but I am not 100% sure yet if I am looking in the right way to all those data.
DOUBLE and INTEGER apparently comprise most of the settings included in document properties and seems coherent with the UI for document properties.
STRING type values (form meat least) are almost empty with the exlusion of a few properties like the name of current drafting standard, units of measure etc.
There are few dialogs like that in Document properties UI so it is probably ok?
TEXTFORMAT gathers all the font related settings so you have to look for every single font related property to be able to properly check them. I locked at swTextformat.TypeFaceName and swTextformat.CharHeight to gather Font name and character heigth and it seems to work as expected. We had some View font mistakenly set with a different font and size compared to our standard and it was discovered at glance.
The TOGGLE category seems to gather most of checkboxes under system option, so ignoring them is probably safe?
My main struggle is with this TOGGLE, I am trying to understand some incoherence I have noticed.
In my registry I have this SW settings
Dumping the UserProperties with API I got
So my registry (actual SW settings) and the dump from API with regards to TOGGLE category do not match apparently. I tried to change those two options in SW and the registry updates as 0 when I uncheck them, but the API still returns FALSE for both swAssemblyAllowComponentMoveByDragging and swAssemblyAllowCreationOfMisalignedMates. Where does this FALSE comes from?
There are a lot of other settings in toggle and some are TRUE and some other FALSE, but I cannot rule out I am reading only some garbage.
Solidworks pulls settings from a lot of locations depending on the user action.
I am focusing on CAD only, excluding PDM, simulation and edrawing from this discussion.
At the end of the day I prefere to have my company SW settings in a readable format, possibily plain text, or a REG file instead of relying on native files only. Native files are basically black boxes and it is difficult to make comparison at glance, having to dig all the settings screen in modelling assembly and drafting as you could miss some hidden option here and there.
This is why I am doing this kind of work, just to clean up all the garbage inside our data and keep track of what must be preserved from one CAD version to the next one.
---
My understanding is that SW system options are stored on a per windows user base inside the windows registry under
Code: Select all
HKCU\software\solidworks\solidworks 20xx
Code: Select all
HKLM\software\solidworks\solidworks 20xx
But looking a bit closer to the above registry keys there are comprised by a lot of subkeys.
Depending on your installation there are over 15,000 unique settings including menus, toolbars, command manager, and other UI customizations. Splitting them in "System option" and "UI and other customizations" makes them more manageable.
Many System Option settings fall under this key and the below subkeys:
Code: Select all
HKCU\software\solidworks\solidworks 20xx\general
There are some specialized subkeys like
Code: Select all
HKCU\software\solidworks\solidworks 20xx\assemblies
This is the simple part, and I think I got it.
What I do not understand is how other specialized keys are used by SW. Take:
Code: Select all
HKCU\software\solidworks\solidworks 20xx\Dimensions
Dimension settings and other document related properties are saved inside the templates files, but roughly half of them can be saved to a drafting standards file.
So having to remake from scratch the templates for the second time, and considering the last time I missed a couple of options (out of 1500+) causing some annoyance in the company, this time I figured out to extract all the documents properties from our existing template using API and I was able to compare the new template (currently under remake) and the legacy one dumping all the settings in two txt files and comparing for differences.
Document settings are apparently divided by data type so you have settings divided in:
DOUBLE
INTEGER
STRING
TOGGLE
TEXT FORMAT(font objects and all their settings)
API Help have ALL the properties methods explained and for each of them the property enumeration (they are solidworks version dependend, sorted by name and there are "internal use only" and "obsolete" properties as well, so be careful when comparing apple with oranges...).
DOUBLE METHOD
https://help.solidworks.com/2022/Englis ... Redirect=1
DOUBLE ENUMERATORS (for the types below I will skip enumerators as they are linked in the method page)
https://help.solidworks.com/2022/Englis ... lue_e.html
INTEGER
https://help.solidworks.com/2022/Englis ... teger.html
STRING
https://help.solidworks.com/2022/Englis ... tring.html
TEXTFORMAT
https://help.solidworks.com/2022/Englis ... ormat.html
TOGGLE
https://help.solidworks.com/2022/Englis ... oggle.html
SAMPLE CODE BUTCHERED FROM API HELP JUST TO SHOW HOW TO GET PROPERTIES
I am working on a more comple macro with UI, but the concept is to dump all the properties and values inside a textbox then compare with notepad++ or winmerge the results from two different templates.
Code: Select all
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim swTextFormat As SldWorks.TextFormat
Dim TextFormatObj As Object
Dim ModelDocExtension As ModelDocExtension
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set ModelDocExtension = Part.Extension
'INTEGER VALUE EXAMPLE
Debug.Print "Tools > Options > Document Properties > Annotations > Balloons > Frame Thickness: " & ModelDocExtension.GetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingBalloonFrameLineThickness, 0)
'DOUBLE VALUE EXAMPLE
Debug.Print "Tools > Options > Document Properties > Annotations > Balloons > Custom Frame Thickness: " & ModelDocExtension.GetUserPreferenceDouble(swUserPreferenceDoubleValue_e.swDetailingBalloonFrameLineThicknessCustom, 0)
'STRING VALUE EXAMPLE
Debug.Print "Tools > Options > Document Properties > Annotations > Balloons > Text Upper Custom property: " & ModelDocExtension.GetUserPreferenceString(swUserPreferenceStringValue_e.swDetailingBOMUpperCustomProperty, 0)
'INTEGER AND TOGGLE
Debug.Print "Tools > Options > Document Properties > Annotations > Balloons > Single balloon - Style: " & ModelDocExtension.GetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingBOMBalloonStyle, 0)
ModelDocExtension.GetUserPreferenceToggle(swUserPreferenceToggle_e.swDetailingBalloonUseDocBentLeaderLength, 0)
End Sub
This makes sense: integer value saves the UI configuration and the double value the real property value itself.
Apparently System option Settings and Document properties seems to be also mixed up in those categories and I ended up dumping all of them, often wondering if I am looking at the current document properties or my system settings. This is quite confusing.
The complete dump for most of the above properties (it excludes font settings like italic on/off etc) is already 1800 lines long. I think was able to compare the document properties of two templates made in SW2022 and SW2023, and I was able to find some mistake I made when I manually set one of our new template, but I am not 100% sure yet if I am looking in the right way to all those data.
DOUBLE and INTEGER apparently comprise most of the settings included in document properties and seems coherent with the UI for document properties.
STRING type values (form meat least) are almost empty with the exlusion of a few properties like the name of current drafting standard, units of measure etc.
There are few dialogs like that in Document properties UI so it is probably ok?
TEXTFORMAT gathers all the font related settings so you have to look for every single font related property to be able to properly check them. I locked at swTextformat.TypeFaceName and swTextformat.CharHeight to gather Font name and character heigth and it seems to work as expected. We had some View font mistakenly set with a different font and size compared to our standard and it was discovered at glance.
The TOGGLE category seems to gather most of checkboxes under system option, so ignoring them is probably safe?
My main struggle is with this TOGGLE, I am trying to understand some incoherence I have noticed.
In my registry I have this SW settings
Code: Select all
HKEY_CURRENT_USER\SOFTWARE\SolidWorks\SOLIDWORKS 2022\Assemblies
Allow Default Move = 1
Allow misaligned mates = 1
Code: Select all
Dumped Under toggle category
swAssemblyAllowComponentMoveByDragging = False
swAssemblyAllowCreationOfMisalignedMates = False
There are a lot of other settings in toggle and some are TRUE and some other FALSE, but I cannot rule out I am reading only some garbage.