# How to create an arrow geometry using python?

I want to create an arrow like in the image using python script. Can someone help me out?

Thanks

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

#Half sizes along Z
half_body_width = body_width / 2.0

#Define the wanted coordinates
coords = [ [body_length, 0.0, half_body_width],       #1
[body_length + head_length, 0.0, 0.0],    #3
[body_length, 0.0, -half_body_width],     #5
[-body_length, 0.0, -half_body_width],    #6
[-body_length - head_length, 0.0, 0.0],   #8
[-body_length, 0.0, half_body_width] ]    #10

#Create the 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 )