Is there a bpy function to convert from blender units to Imperial? something like:

   >>> blender_to_imperial(2.0)
   ... 6.562'

This functionality is present when showing edge lengths, but I can't seem to find a function that can return the conversion.

I found one in the caliper script by macouno, but am wondering if this isn't something that exists already in bpy.

  • $\begingroup$ I don't think imperial merits a tag.. $\endgroup$ – iKlsR Jun 14 '13 at 20:50
  • $\begingroup$ it wasn't an arbitrary tag choice. $\endgroup$ – zeffii Jun 14 '13 at 20:58
  • $\begingroup$ ok, you could document it then. I can't imagine any real use of this tag, it will probably be synonymized into a larger one sooner or later, one that will account for all units. $\endgroup$ – iKlsR Jun 14 '13 at 21:01
  • $\begingroup$ I don't personally use Imperial units, perhaps dimensions or dimensioning would be better $\endgroup$ – zeffii Jun 14 '13 at 21:16
  • 1
    $\begingroup$ if it starts to crop up a lot definitely a meta post - good point and worth talking about. $\endgroup$ – zeffii Jun 14 '13 at 21:30

I found several internal conversion code in the source, like one in view3d_ruler.c for bpy.ops.view3d.ruler(), or in drawobject.c for measurement stats, none of them with direct Python interface. No reference to it, too, in the API manual.

CMIIW, but I think we'll have to write one. All distributed addons so far, like Measure Panel, also write their own conversion function, and it looks like the aforementioned addon have several function we can use directly:

import space_view3d_panel_measure as pm

uinfo = pm.getUnitsInfo()    
print(pm.convertDistance(2, uinfo)) # prints 2.0m, 2.0 BU, or 6.56168'
                                    # depending on selected unit system.
| improve this answer | |
  • $\begingroup$ cool, yeah seems like a basic requirement for international 'precision' based modelling tools, and nice to have a solid implementation to call at will. $\endgroup$ – zeffii Jun 14 '13 at 20:45
  • $\begingroup$ this method works fine @Adhi, thank you! And using it in the edge sum script: gist.github.com/zeffii/3839812 $\endgroup$ – zeffii Jun 14 '13 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.