Units in Global Variables

The Part file contains a global variable that has 'mm' as units at the end as shown in the image attached.

I want to change the value of GV. For that I need to find out the unit used in the GV.
Using API, is there a way to identify the unit used in the GV other than string processing?

I have searched but I can't find any way to do so. Am I missing something?


gvunit.png

Hi

Mmmm... The problem is that equations and variables can include more than one unit. E.g. = 1mm + 1cm

So i think you need to perform string operations to extract each unit. Such " if a number is found in the value (gv string), then, if this number is directly (without any space) followed by alpha characters then get the characters until the next space, and compare them to the sw units list ". Repeat this until the end of gv string to extract all the numbers and their units.

Links about how to get and modify variable and equation value :

https://help.solidworks.com/2020/English/api/sldworksapi/Get_Equation_Values_Example_VB.htm

https://help.solidworks.com/2016/English/api/sldworksapi/Add_Equations_Example_VB.htm

1 « J'aime »