Measure script (Blender 2.5x and newer)

@frigi: Many thanks for the fix of the freeze and drawing issues.
I’ll have to look at the diff to see what it was :slight_smile:

But the 3. change on the other hand (take transpose into account) behaves pretty strange.
If I e.g. move the default cube away from the origin and then select 2 vertices in edit mode the display is definitely wrong now (I can post screenshots if needed).
I didn’t take transpose into account exactly because of situations like this.

EDIT: A saved blend file will never display the measurements again. I guess because “measure_panel_init” is stored as a property in the scene and thus stored in the save file. Once set, the drawing operator will never be added again (even after blender-restart, load & activation of the plugin).

You’re right about both the issues.

Concerning the save problem: I have a fix for that here, will commit in a minute.

I will look into the problem with transpose again. the solution you used was messing with rotations, what I did is now messing with location changes. A combination of both would be good I guess. :wink:

EDIT: Both bugs fixed as of v0.7.5.3

<EDIT: Discussed on IRC and fixed>

Version 0.7.7 of the script is now available

Version 0.7.7 (starting from 0.7.5)

  • Slowdown and strange line drawing should be gone now.
  • API changes for register & unregister functions
  • Global mode is now taking rotation into account properly.

See the [http://"]original post](http://[URL) for the download links.

I see great improvements to you script but strange lines are still here when disabling/enabling ANY script unless on my WinXP with Blender rev.31040 and like I said before I don’t think it’s matter of your script only. See picture below: is it coincidence?

…and it matches, no matter how viewports are sized.

About issue when disabling script from UP while drawing is ON:
adding this line:

 bpy.context.scene.measure_panel_draw = 0 

to unregister() function forces drawing to stop on quit. Not elegant but works.
And here appears another problem with scripts in general. After disabling script in UP, try to type in console above piece of code with value 1 and force redraw ( just move viewport ): measure lines are back. It’s strange but script is still available. What a waste of memory and possible security issue.

I gave up on fixing this (for now), I can’t reproduce it now on my 64bit Linux and my Windows box.
It may even depend on the platform (i.e. Linux/Windows/32bit/64bit).

EDIT: Sometimes they still come back (i think somtimes when switching from/to edit mode)

Yes, that solution works, but (as you noticed) the problem is that the “draw measurement lines” function is still registered and executed on each redraw (even if nothing is shown because of variable=0).
I’ll add some “remove that function” code to “unregister” at some point (i.e as soon as I’ve figured out how to do that). I’ll keep this thread up to date with that.


It looks like the link is dead, and this is a current link:

…Which this goddamn forum won’t let me post, because I just registered, to post it.

Anybody have a working link to, or copy of, Macouno script which worked with blender 2.4?

@Darxus: This script is included in Blender, so just enable this add-on or go to extensions tracker or Blender wiki script catalog to get latest(maybe).
For Macuno’s script go to Blender wiki script catalog for 2.4x - there is a valid link.

Thanks to this thread getting bumped, I just discovered this add-on. I looked at it briefly a little bit today, but I didn’t look real closely at it. Will it measure the length of a curve? While BA was down I needed a way to measure the length of a curve, thanks to google’s cache I was able to find a code snippet that did just that. It basically just converted a curve to a mesh and measured the distance between the verts. pontiac, would you be interested in adding this function to this script?

BTW, I’ve found the pipe joints add-on to be most useful!
Thanks for your work,

the script is currently returning errors.
please see Blender Projects Page for error.
a warning note has been added to svn versions.
thanks, I hope it’s fixed soon.

Thank you for the report, I overlooked the tracker mail notifications for some reason.

The script should work again.
Unfortunately I had to remove the automatic registration of the “draw the lines” callback.
This doesn’t work at all now.

This means that you need to “activate” this (button in the panel) before anything is drawn.

Some way of registering (& unregistering) these callbacks on addon-registration would be pretty cool.

thanks for the quick fix.
it’s good to hear from you :slight_smile:

Yeah, I was pretty busy the last few months (still am), and now I have to read up on all the progress the blender code has seen while I was gone :slight_smile:
Go blender coders, go!

Beside of measuring areas I need to measure normals. Below there is the diff of a rough implementation against the current script version. (I’m not much of a python programmer.) Could something like that be added to your script?

&gt; #
&gt; # Change by TNae (marked by TNae):
&gt; # Measurement of face normals
&gt; #
&gt; ######################################################################
&lt;     return area
&gt; #    return area
&gt;     return area,n
&gt;         nTotal = Vector((0.0,0.0,0.0)); # TNae
&lt;                     areaTotal += faceAreaGlobal(face, obj)
&gt;                     a,n = faceAreaGlobal(face, obj);
&gt;                     areaTotal += a;
&gt;                     nTotal += n; # TNae
&lt;         return areaTotal
&gt;         # return areaTotal;
&gt;         return areaTotal,nTotal; # TNae
&lt;     return -1
&gt;     return -1,Vector((0.0,0.0,0.0))
&lt;                         area = objectSurfaceArea(obj, True,
&gt;                         # area = objectSurfaceArea(obj, True,
&gt;                         #    measureGlobal(sce))
&gt;                         # TNae
&gt;                         area,normal = objectSurfaceArea(obj, True,
&gt;                             sce.measure_panel_normal1 = normal # TNae
&lt;                 area1 = objectSurfaceArea(obj1, False, measureGlobal(sce))
&lt;                 area2 = objectSurfaceArea(obj2, False, measureGlobal(sce))
&gt;                 area1,normal1 = objectSurfaceArea(obj1, False, measureGlobal(sce))
&gt;                 area2,normal2 = objectSurfaceArea(obj2, False, measureGlobal(sce))
&gt;                 sce.measure_panel_normal1 = normal1
&gt;                 sce.measure_panel_normal2 = normal2
&lt;                 area = objectSurfaceArea(obj, False, measureGlobal(sce))
&gt;                 area,normal = objectSurfaceArea(obj, False, measureGlobal(sce))
&gt;                     sce.measure_panel_normal1 = normal
&gt;                                 row = layout.row()
&gt;                                 row.prop(sce, "measure_panel_normal1")
&gt;     bpy.types.Scene.measure_panel_normal1 = bpy.props.FloatVectorProperty(
&gt;         precision=PRECISION,
&gt;         subtype="XYZ") # TNae
&gt;     bpy.types.Scene.measure_panel_normal2 = bpy.props.FloatVectorProperty(
&gt;         precision=PRECISION,
&gt;         subtype="XYZ") # TNae

Is there anyway we can get this script to measure in over measurements besides just BU(Blender Units). Like mm, inches,feet,ect. Thanks so much:)

Just so you know, pontiac, I use your script all the time.
Thank you for the time it took to create it.

Version 0.7.15 is now in blender SVN.

@Nae, I’ve integrated your normals patch into the measure panel (with some modifications).
Also the measured values are now grouped inside a box.

Yes, you can change Blenders unit system to something different (Properties->Scene->Units). The script will use this (where possible) to display the values in the set units.
Mind you that integration of units is not completely working yet (neither in Blender nor the script).

Thank you very much for this script, it’s very helpful (love the surface area esp!). Any chance of an upgrade to add volume measurements as well? I’m currently stuck trucking back and forth between 2.49b and a script for the Shapeways website and 2.5X to do my work, then back to 2.49b to check volumes… And I’m lazy and want to do it all in one place :slight_smile:

If somebody has reliable code for volume calculation I’d include it - might be pretty slow though.
Also there is always the issue of faulty meshes. e.g. duplicate edges/vertices, inverted normals, etc… that might screw up volume calculation - these have to be handled in some way!

What makes this (and area calculation) kind of awkward is that a lot of the calculation is done in python right now - and therefore slow in comparison. I hope in the future there will be a faster way to get this calculated.

Loonsbury and Eric Finley have python code used to make cost estimates in Blender 2.4X for Shapeways 3d-printing at - this code is GPL licensed and seems pretty reliable. They have a separate manifold etc check. Frankly, I’d be happy with a “Warning, run remove duplicates and normals outside before running this script to get reliable results” kind of thing…