I’m having no luck finding a script simple enough that I could successfully adapt into my own, as an addon in 2.57. I’m trying to create an addon to show and hide face normals. There was a thread about this on these forums, with a script posted, but I can’t get it to work. I’m basically stuck, need a working template. Please help!
Got it working! I cobbled this together from various sources:
bl_info = {
"name": "Show Normals",
"description": "Toggles show normals",
"author": "me",
"version": (0,1),
"blender": (2, 5, 3),
"api": 31236,
"location": "",
"warning": "",
"wiki_url": 'http://wiki.blender.org/index.php/Extensions:2.5/Py/' \
'Scripts/System/Blend Info',
"tracker_url": "https://projects.blender.org/tracker/index.php?" \
"func=detail&aid=11",
"category": "Object"}
import bpy
def main(context):
if bpy.context.active_base.object.data.show_normal_face is False:
bpy.context.active_base.object.data.show_normal_face = True
else:
bpy.context.active_base.object.data.show_normal_face = False
class ShowNormal(bpy.types.Operator):
'''Tooltip'''
bl_idname = "object.show_me_normals"
bl_label = "Show Me Normals"
@classmethod
def poll(cls, context):
return context.active_object != None
def execute(self, context):
main(context)
return {'FINISHED'}
def register():
bpy.utils.register_class(ShowNormal)
pass
def unregister():
bpy.utils.unregister_class(ShowNormal)
pass
if __name__ == "__main__":
register()
# bpy.ops.object.show_me_normals()
There’s also
Text Editor --> Text --> Script Templates --> Addon Add Object
Hallo, you should check for objects, which can have a normal (meshes e.g. bpy.context.activ_object.type == “MESH”)
Put you file into …/scripts/addons and activate!