Get system units

Hello,

Is there any way you can get the current system unit type, store it, change the systemtype for your script and restore the system type to the original one at the end of your script?

Example :

My script works in meters but the guy using it is set up in inches.
How do I get to know if he has inches, feet, ... so I can temporary change the setup in meters for my script to work properly and then restore it to inches so the user has no problems.

I know how you can set the units ==> " units.SystemType = #meters "
but I don't know how to get the current units
If i try ==> " Variable = units.SystemType " I get an error...

grtz

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

This also works.( case

This also works.

( 
	case units.DisplayType of
	(
		#Generic:
		(
			case units.SystemType of
			(
				#Inches: "In"
				#Feet: "ft"
				#Miles: "miles"
				#Millimeters: "milim"
				#Centimeters: "canti"
				#Meters: "meters"
				#Kilometers: "kilometers"
			)
		)
		#metric: 
		(
			case units.MetricType of 
			(
				#millimeters: "mm"
				#meters: "m"
				#centimeters: "cm"
				#kilometers: "km"
			)
		)
		#US:
		(
			case units.USType of
			(
				#Frac_In: "frac In"
				#Dec_In: "dec In"
				#Frac_Ft: "frac ft"
				#Dec_Ft: "dec ft"
				#Ft_Frac_In: "ft frac"
				#Ft_Dec_In: "ft dec"
			)
		)
	)	
)

In the listener will be printed the current unit type

jos's picture

var = units.SystemType works

var = units.SystemType works fine here...

pieterjanvc's picture

It does...

Very weard... I tested it again and it does work indeed!

Thank you !! Maybe I messed up the part of the script where I put it in.
Sorry for the trouble : )

Grtz

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.