Normal to Surface constraint addon

My first python script addon for Blender. Probably lots of nooby errors and bugs but we all need to start somewhere :D. C&C are welcome !

The normal to surface constraint is an addon in python for Blender that calculates the normal vector to a mesh and applies it to the object. Strangely, this is one of the constraint that doesn’t exist and that I’d like to see in Blender.
You can find it here : https://github.com/StanPaillereau/Blender_Addons

The addon creates 2 buttons in the “tool panel” > “Relations” > “Create Normal To Surface constraint” to add/remove the constraint :

https://m1.behance.net/rendition/modules/140473411/disp/1b45c2a7b183ea1efe6b838fc9c7d66d.png

Once the constraint is added to an object, a set of buttons appears in the UI panel ( > “Custom Constraints”). They allow you to change targets/normal axis/up axis, enable/disable or delete the constraint :

https://m1.behance.net/rendition/modules/140473413/hd/66b9549ce149f2f64f6dec9f50e99f01.png

Would it work to make for instance a control slide over a surface or maybe a cartoony pupil slide through an eyeball’s geometry?

Cheers!

interesting, could be useful for floating objects on a water sim

Hi Spallier,

I have this traceback with my last release of Blender:


Traceback (most recent call last):
  File "/home/patrinux/.config/blender/2.76/scripts/addons/normal_to_surface.py", line 80, in DeclMesh
    obj_active = bpy.context.active_object
AttributeError: 'Context' object has no attribute 'active_object'

Blender:
version 2.76 (sub 0), branch b’master’, commit date b’2015-09-30’ b’16:05’, hash b’fb78f6d’, b’RelWithDebInfo’
build date: b’2015-10-02’, b’18:23:40’
platform: b’Linux’