{"id":169,"date":"2016-12-07T18:14:52","date_gmt":"2016-12-07T18:14:52","guid":{"rendered":"http:\/\/stuff.wp.viranyi.com\/?p=169"},"modified":"2019-03-04T13:08:39","modified_gmt":"2019-03-04T13:08:39","slug":"blender-flatten-normals-of-mesh-data-in-bulk","status":"publish","type":"post","link":"http:\/\/stuff.wp.viranyi.com\/?p=169","title":{"rendered":"Blender &#8211; Flatten normals of mesh data in bulk"},"content":{"rendered":"<p>Recently I had to fix per-face-vertex normals for a project and I had to come up with a script snippet to ease the manual touches involved in the task.<\/p>\n<p>Run this script on any selected object in Object Mode.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">import bpy\nprint(\"Flattening per face normals ..\")\ncurrent_obj = bpy.context.active_object\n# Calc\ncurrent_obj.data.calc_normals_split()\n# Vertex-per-face Normals\nn = []\nfor face in current_obj.data.loops:\n    n.append(face.normal.copy())\n    n[face.index][1] = 0\n    n[face.index] = n[face.index].normalized()\n    print(\"i\", face.index , \"n\", face.normal, \"n2\", n[face.index])\n\ncurrent_obj.data.normals_split_custom_set(n)\ncurrent_obj.data.update()    \ncurrent_obj.data.free_normals_split()\nprint(\"Done.\")<\/pre>\n<p>After execution you may change into Edit Mode and see the normals flattened.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I had to fix per-face-vertex normals for a project and I had to come up with a script snippet to ease the manual touches involved in the task. Run this script on any selected object in Object Mode. import bpy print(&#8220;Flattening per face normals ..&#8221;) current_obj = bpy.context.active_object # Calc current_obj.data.calc_normals_split() # Vertex-per-face Normals [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[],"class_list":["post-169","post","type-post","status-publish","format-standard","hentry","category-blender","category-fml"],"_links":{"self":[{"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=\/wp\/v2\/posts\/169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=169"}],"version-history":[{"count":2,"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=\/wp\/v2\/posts\/169\/revisions"}],"predecessor-version":[{"id":212,"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=\/wp\/v2\/posts\/169\/revisions\/212"}],"wp:attachment":[{"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/stuff.wp.viranyi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}