Vertex Normal editing

Hi guys! i want make a script (maybe add ons) that make possible to edit vertex normal (change their angle), but i’ve found some issues: i want make vertex normal visible in automaitic by calling the relative command (bpy.types.Mesh.show_normal_vertex). but the console report that there is no attribute with this name, why?. Another question, first of all, is possible to modify the normal vertex of an object with the API?

With obj as your object, you can use:

obj.data.show_normals_vertex = True #show vertex normals
bpy.context.tool_setting.normal_size = 0.05 #change the display size for normals

I may be wrong, but in my experiences with editing vertex normals:
1. the object must be in Object mode
2. once you have made edits, you cannot change to edit mode for that object, or Blender will automatically re-calculate the normals
3. sometimes, the results of your edit may not show(this usually happened if I had a material applied).

ok thank for your reply! my intent is to change the angle of vertex normal like in “3d max”, so when i export foliage mesh in UDK, it can light the mesh better. this is because the mesh is a plane with 2 sided material. so for light it better i need this.
i see that in a tutorial but blender can’t do this… for the moment :D.

i’ll try it! thanks again

don’t work this time console report

[‘cube’].data.show_normals_vertex = True

Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
AttributeError: ‘list’ object has no attribute ‘data’

You can’t just say [‘cube’], you either have to use

bpy.data.objects['cube']

or assign the object to a variable:

obj = bpy.data.objects['cube']
obj.data.show_normals_vertex = True #show vertex normals
bpy.context.tool_setting.normal_size = 0.05 #change the display size for normals

i used [‘cube’] because is the result of this expression

bpy.context.selected_objects
i’ve already try your code but don’t work (i’m trying it on the console directly, is a problem??)
if i use instead this??

 obj = bpy.context.selected_object #so it works on the selected object 
obj.Data.show_normals_vertex = True

Well that’s not a particular object. You could use

obj = bpy.context.active_object

i’ll try wait a moment…

no… the error now is

Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
AttributeError: ‘Mesh’ object has no attribute ‘show_normals_vertex’

Sorry, its ‘show_normal_vertex’ (not ‘normals’).

I’m pretty sure (unless they changed it) that if you edit the normals and then tab into/out of edit mode they all get recalculated when blender converts the editmesh -> mesh. Or the other way around.

Something like that at least…

ok this time it works!!! but as you and Uncle Entity said, when i return in edit mode it recalculate the normals… I try to export the edited mesh too but it don’t export the normal as i want.

there is a funcion o something like that to disable this, because i can’t export the mesh with custom normal…

now i’m trying to use a manipulator for editing the normal but i think is impossble, because we can’t operate in edit mode, right?

there is a way to use the translate o rotate maipulator to change the vertex normal?

i really looking forward to your script… do you have already something to try out? would be amazing!

really yes, but as i wrote you can’t export the edited normal, and you can’t return in edit mode after recalculation, because when you return in edit mode, normals are atumatically recalculated by blender, and as i understand at momen there is no way to disable this, this is a pretty big problem… otherwise if you want the script i’ll upload it, but you can only use it on script editor, and you have to change the normal value manually on the script. if you like it let me know!!

For my exporter, I wrote a function that set the vertex normals the way I want, then called it after any instance where I would need to go into Edit mode. It sucked to do it that way, but it works.

what exporter you use?

I wrote one to export meshes to be used for objects in The Sims 3.

this is the script

bl_info = {
    "name": "Vertex_Normals_eding",
    "author": "Rebellion",
    "version": (1, 0),
    "blender": (2, 6, 0),
    "api": 33333,
    "location": "View3D &gt; Edit_Mode &gt; Mesh &gt; Normals &gt; Edit_vertex_normals",
    "description": "Edit_vertex_normals",
    "warning": "",
    "wiki_url": "",
    "tracker_url": "",
    "category": "Mesh"}


import bpy
from bpy.props import FloatVectorProperty ,IntProperty
import mathutils

   



#operator
class Normal_ops(bpy.types.Operator):
    
     bl_idname = "bpt.normal_op" 
     bl_label = "Vertex Normal Edit"
     bl_description = "Vertex Normal Edit" #optional
    
        
     def execute(self, context):      #convert in modal
         
         #var
         obj = bpy.context.active_object
         vert_index = len(bpy.context.active_object.data.vertices)
         coord = mathutils.Vector((1, 0, 0))
         
         #begin
         
         obj.data.show_normal_vertex = True
         
         bpy.ops.object.mode_set(mode='OBJECT')
        
         for n in range (vert_index):
             
            obj.data.vertices[n].normal= coord
            
         
         bpy.ops.object.mode_set(mode='EDIT')
         return {'FINISHED'}

def Menu_append(self, context):
    self.layout.separator()
    self.layout.operator(Normal_ops.bl_idname, text="Vertex Normal Edit")
 
                
def register():       
    bpy.utils.register_class(Normal_ops)
    bpy.types.VIEW3D_MT_edit_mesh_normals.append(Menu_append)


  
if __name__ == "__main__":
    register()

thanks for the script!

… it seems that the normals get recalculated when leaving edit-mode.

i made the script available in object mode, changed the normals and exported as fbx… guess what? it worked for me with unity3d! :smiley:

all i need now is a way to apply manual normal vectors to specific vertex groups…