Convert to project units

Hello,

I want to move a view on a sheet by a specific mm value.
I want this to work no matter what the project units are.

I got it working by getting the project units and searching for the unit name, then filter different values by bool mask.

I just wanted to know if there is any better way to do this!? Happy about any thoughts!