How do I create a triangle in python?

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

truenoeks
Posts: 8
Joined: Wed Oct 16, 2002 8:47 pm

How do I create a triangle in python?

Could someone please provide some code for creating a triangle with python

--or--

Tell me why the following code

--------------------------------------------------
import Blender

from Blender import Mesh, Scene, Object
from math import *

def DrawCircle():
# Create Mesh
CircMesh = Mesh.New()

# Set Middle Vertice Coords
MidVert = [0.0, 0.0, 0.0]

# Set Start Angle
Angle = 0.0

# Calculate Vert Coords
Vert = [0.0, 0.0, 0.0]
Vert[0] = 0.5 * cos(Angle)
Vert[1] = 0.0
Vert[2] = 0.5 * sin(Angle)

VList = []
for i in range (0, 32):

# Add Middle And Vert
Angle = 2 * pi * i / 32
NextAngle = 2 * pi * (i + 1) / 32

# Calc Next Vert Coords
NextVert = [0.0, 0.0, 0.0]
NextVert[0] = 0.5 * cos(NextAngle)
NextVert[1] = 0.0
NextVert[2] = 0.5 * sin(NextAngle)

# Get ready to go again
Vert = NextVert

LINE 35 --> CircMesh.update()

CircObj = Object.New('Mesh')
ThisScene = Scene.getCurrent()

Blender.Redraw()

DrawCircle()
----------------------------------------------------

Gives the following error message:

Traceback (most recent call last):
File "DrawCircle.py", line 44, in ?
File "DrawCircle.py", line 35, in DrawCircle
File "../modules/Blender/Mesh.py", line 203, in update
File "../modules/Blender/Mesh.py", line 69, in toTriangles
ImportError: No module named utils