Measure script (Blender 2.5x and newer)

To learn a bit about panels I’ve created a script that measures the distance of selected objects and the 3D cursor (this depends on what is selected).

To be honest I didn’t search if something like this already exists (for 2.5 that is, I know of the 2.4x scripts [1] and [2]).
As already mentioned I did this to learn a bit about the panel API stuff in 2.5.

Usage

This script displays in OBJECT MODE:

  • The distance of the 3D cursor to the origin of the 3D space (if NOTHING is selected).
  • The distance of the 3D cursor to the center of an object (if exactly ONE object is selected).
  • The distance between 2 object centers (if exactly TWO objects are selected).
  • The surface area of any selected mesh object.

Display in EDIT MODE (Local and Global space supported):

  • The distance of the 3D cursor to the origin (in Local space it is the object center instead).
  • The distance of the 3D cursor to a selected vertex.
  • The distance between 2 selected vertices.
  • The surface area of any selected face.

It’s very helpful to use one or two “Empty” objects with
“Snap during transform” enabled for fast measurement.


http://wiki.blender.org/index.php/File:Blender_measure_panel_script.JPG

Open issues / TODO

  • Get units to work with the script (Right now only raw blender units are used, not metric/imperial stuff)
  • Lamps and other objects are not show with their correct icon … dunno if this is a good idea?
  • Icon for absolute origin (is there one?)
  • Measurements in Edit Mode have to be updated manually. Not much I can do here, this is a problem that is in Blender quite some time now.

Download

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
IMPORTANT NOTE!
gitorious.org has been discontinued. There is (was?) still a read-only mirror of the former gitorious.org site available - which doesn’t seem to work anymore?

Anyway, the last version is also available in the “Blender Add-ons Contrib” (BAC) Blender code repository:

https://developer.blender.org/diffusion/BAC/browse/master/space_view3d_panel_measure.py
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

THE INFO BELOW IS OUTDATED!

Link to the script
(Save the “Raw data blob” link there as a file into your .blender/scripts/addons/ directory.
You can then enable the plugin in the User Preferences under Add-Ons.)

Alternatively: Direct download link (right-click and save) to the most recent version:
http://gitorious.org/blender-scripts/blender-measure-panel-script/blobs/raw/master/space_view3d_panel_measure.py

If the version does not match the most recent version reported in the thread you can also try to download the script from the blender-addons GIT repository (most of the time I’ll upload this version first):
https://developer.blender.org/diffusion/BA/browse/master/space_view3d_panel_measure.py
(View Raw File -> Download File)

Script homepage
http://gitorious.org/blender-scripts/blender-measure-panel-script

Cheers,
Martin

[1] http://blenderartists.org/forum/showthread.php?p=82499
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_3dcursorposition.htm#distancedunpointaucurseur3d
[2] http://wiki.blender.org/index.php/Extensions:Py/Scripts/CAD/MeasureMesh

HI,

Nice example script have you thought about adding it to this link:

http://blenderartists.org/forum/showthread.php?t=164765

Also there is a wiki entry on python for 2.5 you may be interested in:

http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro

Good work pontiac. I also interested in 2.5 scripts. Thanks for sharing.

I’ve updated the original post with new links to the final script homepage & downlaod location.
No new features or anything though.

Thanks.
I’ve posted a link to the measure panel thread there.

I read (some of) that, but thanks for the link anyway :wink:

Martin

Version 0.2.1 of the script is now available
Distance values can now be copied to the clipboard (like any other value in Blender).

See the original post for the download links.

Version 0.3.1 of the script is now available
Support for mesh edit mode.
Up to 2 vertices can be selected.
The distances for the various combinations are calculated exactly like in object mode.

See the original post for the download links.

some ideas, I didnt test so maybe they dont apply

  • Rather then a number input, if this is only for display it could be a label with your own text?
  • You could abuse grease pencil to draw the lines in the 3D display - python can modify grease pencil points though I didnt test adding new grease pencil data yet.

macouno also had a similar script that I used . . . it did the job. Yours seem quite neat too.

great job,

here’s the link to macouno’s script.
http://wiki.blender.org/index.php/Extensions:Py/Scripts/CAD/MeasureMesh
I think that’s the type of thing ideasman was getting at.
To be able to use visual links/guides is sometimes desirable.

thanks.

Yes, that’s how the value got displayed in the very fist version of the script.

Unfortunately one can’t copy a lable text into the clipboard (at least I couldn’t find a way).
So one can measure something, copy the value and use it somewhere else.
(That was one of the reasons why I asked about the FloatProperty stuff on IRC.)

I’ll have a look at the grease pencil stuff. Looks like a good idea.
A non-permanent (i.e. never saved) solution for this would be better in the long run though.
OpenGL drawing (and the temporary FloatProperty for the situation above) would be helpful - but I can manage until then :slight_smile:

Thanks for the link, I’ve added this to the original post.
I’ve planned to add various measurements like this to the script, but I’m still working out the details.

Couldn’t agree more, but until somthing like this is integrated into the script may take some time.

Martin

Version 0.4 of the script is now available

  • Fixed calculation & display of local/global coordinates in edit mode.
    The user can select the space via a toggle switch.
    Basically this is a bugfix and new feature at the same time :slight_smile:
  • Calculate & display the surface area of mesh objects (local space only right now).

See the original post for the download links.

which 2.5 version are you using ?
i got 26162

where do you upoad this script
is it OP folder ?

when i change the location fo the cursor i don’t see the update of the dist
how can i see it ?
i mean if i wait about 5 seconds then i see it update in N panel
this is sa little slow!

anything i more i have to do to see it faster ?

Distance
this is the root means square distance between 2 points in space right !

the X Y Z values would be the one in Transform panel
and the dist in 3D is the value you calculated

Suggestion
now one suggestion here can you give the 2 angles in 3D for this distance vector
i mean this would give the whole picture for this distance - vector

by angle i mean like if you where in Spherical coordinates system
one angle around Z and one between vector and floor

i can make a dwg if you need to let me know

Area
where would i see this area ?

Thanks

I’m currently using r26373 (fresh from svn).

Anyway, r26162 is much too old.
You need at least r26317.
http://lists.blender.org/pipermail/bf-blender-cvs/2010-January/025519.html

vekoon fixed a bug there where a change of 3D cursor position didn’t update the panels.

Fix for 3d view’s properties region notifier: 3D cursor position was not updated

If you can’t get a more recent version yet you can force the update by quickly switching into editmode/object mode and back [TAB]. Or selecting something.

well ok i’ll get the latest version should be better anyway for eveything else ! LOL

you seems to be using SVN meaning that you are building your vesion?

i never did that on windows

i use the built version from

hope this can work ?

Thanks

No need for a drawing, I know what you are talking about.

I was thinking about adding angles, but for that I’d need some sort of graphical display (in the 3D view) first.

Look at the original post, the screenshot should be updated with the most recent look of the panels. (try force-reloading the web page of the thread if no “area” stuff is in the image)

Yes (Lin&Win), this is the only way to quickly get the bugfixes and new code the blender programmer gods keep creating :RocknRoll:

Yes, these builds normally work pretty well.

We really need a way to draw in the Viewports etc.

I want to make a script (like I did for 2.49) which shows the pressed keys for video tutorials.

Carsten

ok installed the 363 for windows

the distance is updating a lot faster in real time

but if i scale the object or change the scale in transform panel

it does not change the area in your panel

is this a bug or normal ?

Vector
as i suggested will you add the angles for this distance vector !
it would be more complete i guess

Thanks nice gadget

This is normal. That’s what “local” means in the context of mesh objects.
The calculated value is the surface area of the un-scaled object.
The “Global” value is on my to-do list.

Version 0.5 of the script is now available

  • Global surface area (object mode) is now calculated as well. i.e. scaling is applied.
  • Support area calculation for face selection in edit mode
    (This seems to cause some problems because of the constant exiting/re-entering of editmode :(. Not much I can do there - I think.).
  • Made measurement panel closed by default.
  • Internal cleanup

See the original post for the download links.