Check delimiter through API

Programming and macros
berg_lauritz
Posts: 423
Joined: Tue Mar 09, 2021 10:11 am
Answers: 6
x 439
x 233

Check delimiter through API

Unread post by berg_lauritz »

I just wrote a quick and dirty macro to import some dimensions that you set in a .txt file (basically because the import equations option in Solidworks is simply SO BAD!). Now I am trying to change the delimiter to the one that is used on this machine - but nothing seems to work:

Code: Select all

    
    Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim ModelDocExtension As SldWorks.ModelDocExtension

Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set ModelDocExtension = swModel.Extension
    
    Dim docUserUnit As SldWorks.UserUnit
    Set docUserUnit = swModel.GetUserUnit(swLengthUnit)
    Debug.Print "Decimal separator character: " & docUserUnit.SeparatorCharacter
 End Sub
This always returns
Decimal separator character: .
!
But the global decimal separator is actually a comma (I'm back in Germany here).
How do I access the global one?
by berg_lauritz » Wed Jan 03, 2024 8:27 am
gupta9665 wrote: Wed Jan 03, 2024 7:02 am Have you looked at swUserPreferenceToggle_e.swUseSystemSeparatorForDims method?
I did (here), but that's just the toggle & if it is activated.

But I did find the answer now after pursuing this further, I just needed a nudge from you @gupta9665, thank you!
This prints the character for dimensions:

Code: Select all

Dim stringstatus As String
    stringstatus = swApp.GetUserPreferenceStringValue(swSeparatorCharacterForDims)
    Debug.Print stringstatus
It's hidden here:
https://help.solidworks.com/2021/englis ... lue_e.html
Go to full post
User avatar
gupta9665
Posts: 405
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 426
x 445

Re: Check delimiter through API

Unread post by gupta9665 »

Have you looked at swUserPreferenceToggle_e.swUseSystemSeparatorForDims method?
Deepak Gupta
SOLIDWORKS Consultant/Blogger
berg_lauritz
Posts: 423
Joined: Tue Mar 09, 2021 10:11 am
Answers: 6
x 439
x 233

Re: Check delimiter through API

Unread post by berg_lauritz »

gupta9665 wrote: Wed Jan 03, 2024 7:02 am Have you looked at swUserPreferenceToggle_e.swUseSystemSeparatorForDims method?
I did (here), but that's just the toggle & if it is activated.

But I did find the answer now after pursuing this further, I just needed a nudge from you @gupta9665, thank you!
This prints the character for dimensions:

Code: Select all

Dim stringstatus As String
    stringstatus = swApp.GetUserPreferenceStringValue(swSeparatorCharacterForDims)
    Debug.Print stringstatus
It's hidden here:
https://help.solidworks.com/2021/englis ... lue_e.html
Post Reply