Script to measure distance

Hello, I’ve found a script for distance measure here

I wrote this script to answer a question on the
french zoo-logique.org/3D.Blender forum.

You can find an improved version here:
http://jmsoler.free.fr/util/blenderfile/callipersquare03.zip

very cool jms

Tried the script in callipersquare03.zip, but in blender 235 it just loops endlessly.

Before i found this thread i made a small script myself:
https://blenderartists.org/forum/viewtopic.php?p=341084#341084

Pontiac

a new script that replaces the callliper square one:
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_3dcursorposition.htm#distancedunpointaucurseur3d
http://translate.google.com/translate?u=http%3A%2F%2Fjmsoler.free.fr%2Fdidacticiel%2Fblender%2Ftutor%2Fcpl_3dcursorposition.htm%23distancedunpointaucurseur3d&langpair=fr|en&hl=fr&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_tools

Thanks for the info&link.

1 question though:
What could be the reason that the BGL line isn’t drawn?
You mention on your site that the script needs to be attached to an object not a scene, but what does this mean… or better how do i do that?

Thanks
Pontiac

Sorry,

just rename the script : mesure.py

No change in behaviour.
The only feedback/error i get is this error when I first start the script (without selecting anything):

Traceback (most recent call last):
  File "<string>", line 57, in ?
AttributeError: no such Blender Text.

The created Empty is resized and its text changed every time i start the script after that.

Thanks again fopr your help,
pontiac

Very curious. If you have a moment to try this file:
http://jmsoler.free.fr/util/blenderfile/py/mesure.blend

This file seems to work just fine.
The line is drawn and the text is updated on move… cool 8)

I think in the .py file the link to the generated object (however this works) isn’t created correctly (but it may be my fault :? )

(Just to get sure i also tried to use the source from the .blend file in the .py file, but the line-drawing didn’t work here too.)

Pontiac

You can use shift-f1 to import the script
edit the script and do a alt-p on the text window.

When i try to load the “mesure.py” fille i get the error “ERROR: Not a library”

But the script contained in the .blend (e.g …/mesure.blend/Text/mesure.py) file is no problem to use as a library… works as expected, but needs to be loaded verytime i start blender :?

(After loading as lib i can also use the script over the Misc menu instead of the Alp-P in Text-Window)

Pontiac

PS: I’m still using Blender 2.35 if that makes any difference.

You can download the script with the correct name now.

If you mean this file:
http://jmsoler.free.fr/util/blenderfile/py/mesure.py

It still says “ERROR: Not a library” when importing it with SHIFT+F1
(A sidenote: And in this file the registration with the menu is missing too… which is quite handy)

I hope i don’t bug you too much since it’s just a minor problem to reload the script at every blender start :wink:
If so just ignore me and my whining :smiley:
Pontiac

Ok, i added the script into my “User defaults” setting, so no more reloading the script for me :smiley:
Didn’t know that this is possible before.

Thanks again for this little helper :smiley:
Pontiac

I hope i don’t bug you too much since it’s just a minor problem to reload the script at every blender start :wink:
If so just ignore me and my whining :smiley:
Pontiac

if you find it usefull save this script with the current file in the Default Settings with the shortcut : ctrl-u .

I did a little improvment, try to reload the script from its url
I think that it could be loaded from the script menu now.

(thx for all your comments )

That’s what i did one posting above (last page) :wink: … you just missed it :smiley:

I did a little improvment, try to reload the script from its url
I think that it could be loaded from the script menu now.

(thx for all your comments )

Just tried it and it seems to even work without having to load it as a library.
I’ll test it and comment here.

Many thanks,
Pontiac

The script is working fine so far, one thing about the code though:

Shouldn’t this part of the code

     if E.getScriptLinks('Redraw')== None : 
        E.addScriptLink('mesure.py','Redraw')
     elif 'mesure.py' not in E.getScriptLinks('Redraw'): 
        E.addScriptLink('mesure.py','Redraw')

be replace with this:?

     if E.getScriptLinks('Redraw')== None : 
        E.addScriptLink(NAME,'Redraw')
     elif NAME not in E.getScriptLinks('Redraw'): 
        E.addScriptLink(NAME,'Redraw')

…since there is now a variable to specify the script-name

EDIT: and a version entry would be great to keep track of the changes made to the script … e.g:

__version__ = "0.1.0"

Just my 2c
Pontiac

Updated :
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_3dcursorposition_en.htm#distancedunpointaucurseur3d