I want to create an arrow like in the image using python script. Can someone help me out?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
a very flexible way to do that is to use the Rigify addon. You enable it in the User Preferences -> Addons tab, look for Rigify and check it.
Now, if you go to Edit Mode of ANY mesh, there's a button in the Transform Panel:
Rigify now creates the code needed to make this Object via Python. Go to a Text Editor, and select widget.py:
This is all the code you need, wrapped in a nice Python function. So to recap: Model your Mesh as you wish it to be, Apply all modifiers, and encode it using Rigify Dev Tools.
What matters here is the order in which vertices are used to create the unique face of the arrow.
I have chosen to set them clockwise.
import bpy import bmesh #Size parameters body_length = 4 body_width = 0.6 head_length = 1.1 head_width = 1 #Half sizes along Z half_body_width = body_width / 2.0 half_head_width = head_width / 2.0 #Define the wanted coordinates coords = [ [body_length, 0.0, half_body_width], #1 [body_length, 0.0, half_head_width], #2 [body_length + head_length, 0.0, 0.0], #3 [body_length, 0.0, -half_head_width], #4 [body_length, 0.0, -half_body_width], #5 [-body_length, 0.0, -half_body_width], #6 [-body_length, 0.0, -half_head_width], #7 [-body_length - head_length, 0.0, 0.0], #8 [-body_length, 0.0, half_head_width], #9 [-body_length, 0.0, half_body_width] ] #10 #Create the mesh bpy.ops.object.add(type='MESH') #Get the object obj = bpy.context.object #Get the mesh data mesh = obj.data #Create a bmesh instance in order to add data (vertices and faces) to the mesh bm = bmesh.new() #Create the vertices for coord in coords: bm.verts.new( coord ) #Add a face with all the vertices (the vertices order matters here) bm.faces.new( bm.verts ) #Updates to Blender bm.to_mesh(mesh) mesh.update()