Standard / imperial unit system change - short cut
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Standard / imperial unit system change - short cut
instead of going to Preferences -> Units and switching, is it possible to make a shortcut/tool bar button?
Re: Standard / imperial unit system change - short cut
You can use a macro which is bound to an icon. See e.g. the macro FC_SU, which changes some preferences: https://forum.freecadweb.org/viewtopic.php?t=41265.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Standard / imperial unit system change - short cut
hi
create a button and use this snippet , click the button increment the counter and the unit option is activated and displayed in the Report view
mario
create a button and use this snippet , click the button increment the counter and the unit option is activated and displayed in the Report view
Code: Select all
#16/05/2020
#Mario52
#https://forum.freecadweb.org/viewtopic.php?f=3&t=46393
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("UserSchema")
p += 1
if p > 7:
p = 0
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").SetInt("UserSchema", p)
if p == 0:
pp = "Standard (mm/kg/s/degree)"
elif p == 1:
pp = "MKS (m/kg/s/degree)"
elif p == 2:
pp = "US customary (in/lb)"
elif p == 3:
pp = "Imperial decimal (in/lb)"
elif p == 4:
pp = "Building Euro (cm/m2/m3)"
elif p == 5:
pp = "Building US (ft-in/sqft/cft)"
elif p == 6:
pp = "Metric small parts e CNC(mm, mm/min)"
elif p == 7:
pp = "Imperial for Civil Eng (ft, ft/sec)"
print(p,":",pp)
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Standard / imperial unit system change - short cut
Just curious.
What is the use case for switching back and forth?
Is it because you forgot before starting the file?
Is it because you want to enter inches in a constraint, but are in metric?
In the later case simply delete the contents of the box (including the units, for example mm), then type 10".
The resulting value will be 254mm.
For 1 1/4": clear the box, type (1+(1/4))". (or if you happen to know the decimal value, 1.25". (I tend to use the fraction...since, I typically don't remember, for example, what 31/32" is in decimal )
Just FYI.
What is the use case for switching back and forth?
Is it because you forgot before starting the file?
Is it because you want to enter inches in a constraint, but are in metric?
In the later case simply delete the contents of the box (including the units, for example mm), then type 10".
The resulting value will be 254mm.
For 1 1/4": clear the box, type (1+(1/4))". (or if you happen to know the decimal value, 1.25". (I tend to use the fraction...since, I typically don't remember, for example, what 31/32" is in decimal )
Just FYI.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Standard / imperial unit system change - short cut
Thank you chrisb, mario and drmarco.
Never knew how to enter mixed fractions , very helpful.
Everything else is real awesome, using mm and inches back and forth all the time.
Etsy seller here making custom cuts for anyone.
Using FreeCAD for everything and to send snaps to customers. Who are all over world, some metric, some imperial. I end up switching it every 10 minutes sometimes.
(dimensions actually I have lots problem with, can't figure out good way)
Never knew how to enter mixed fractions , very helpful.
Everything else is real awesome, using mm and inches back and forth all the time.
Etsy seller here making custom cuts for anyone.
Using FreeCAD for everything and to send snaps to customers. Who are all over world, some metric, some imperial. I end up switching it every 10 minutes sometimes.
(dimensions actually I have lots problem with, can't figure out good way)
- Attachments
-
- Screenshot_2020-04-20_11-06-21.png (220.47 KiB) Viewed 1349 times
-
- shelf_1.png (27.1 KiB) Viewed 1349 times
-
- oops.png (80.75 KiB) Viewed 1349 times
-
- scale2.png (38.35 KiB) Viewed 1349 times
-
- nat3.png (36.83 KiB) Viewed 1349 times
Re: Standard / imperial unit system change - short cut
This does swap it, but changes don't take effect until I run Preferences, Units, OK.mario52 wrote: ↑Sat May 16, 2020 9:57 am hi
create a button and use this snippet , click the button increment the counter and the unit option is activated and displayed in the Report viewmarioCode: Select all
#16/05/2020 #Mario52 #https://forum.freecadweb.org/viewtopic.php?f=3&t=46393 p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("UserSchema") p += 1 if p > 7: p = 0 FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").SetInt("UserSchema", p) if p == 0: pp = "Standard (mm/kg/s/degree)" elif p == 1: pp = "MKS (m/kg/s/degree)" elif p == 2: pp = "US customary (in/lb)" elif p == 3: pp = "Imperial decimal (in/lb)" elif p == 4: pp = "Building Euro (cm/m2/m3)" elif p == 5: pp = "Building US (ft-in/sqft/cft)" elif p == 6: pp = "Metric small parts e CNC(mm, mm/min)" elif p == 7: pp = "Imperial for Civil Eng (ft, ft/sec)" print(p,":",pp)
Re: Standard / imperial unit system change - short cut
hi
how many units do you use and which ones (listed in the macro)
mario
how many units do you use and which ones (listed in the macro)
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Standard / imperial unit system change - short cut
Standard (mm/kg/s/degree)
and
US customary (in/lb)
Need to cycle between the two.
and
US customary (in/lb)
Need to cycle between the two.
Re: Standard / imperial unit system change - short cut
Be careful!
"US Customary" is anything but customary. It is likely that you want "Imperial decimal".
This has recently been discussed in
Code: Select all
https://forum.freecadweb.org/viewtopic.php?f=3&t=46222
Re: Standard / imperial unit system change - short cut
hi
i modify the macro flip/flop to Standard (mm/kg/s/degree)/US customary (in/lb)
run the macro the preference window is displayed click directly Ok for validate
mario
i modify the macro flip/flop to Standard (mm/kg/s/degree)/US customary (in/lb)
run the macro the preference window is displayed click directly Ok for validate
Code: Select all
#16/05/2020:20/05/2020
#Mario52
#https://forum.freecadweb.org/viewtopic.php?f=3&t=46393
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("UserSchema")
#p += 1
#if p > 7:
# p = 0
#FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").SetInt("UserSchema", p)
#if p == 0:
# pp = "Standard (mm/kg/s/degree)"
#elif p == 2:
# pp = "US customary (in/lb)"
#elif p == 3:
# pp = "Imperial decimal (in/lb)"
#elif p == 4:
# pp = "Building Euro (cm/m2/m3)"
#elif p == 5:
# pp = "Building US (ft-in/sqft/cft)"
#elif p == 6:
# pp = "Metric small parts e CNC(mm, mm/min)"
#elif p == 7:
# pp = "Imperial for Civil Eng (ft, ft/sec)"
if p == 0:
p = 2
pp = "US customary (in/lb)"
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").SetInt("UserSchema", p)
elif p == 2:
p = 0
pp = "Standard (mm/kg/s/degree)"
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").SetInt("UserSchema", p)
else:
p = 0
pp = "Standard (mm/kg/s/degree)"
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").SetInt("UserSchema", p)
print(p,":",pp)
Gui.runCommand('Std_DlgPreferences',0)
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.