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
VList.append(CircMesh.addVert(MidVert))
VList.append(CircMesh.addVert(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)
# Add NextVert
VList.append(CircMesh.addVert(NextVert))
# Get ready to go again
Vert = NextVert
CircMesh.addFace(VList)
LINE 35 --> CircMesh.update()
CircObj = Object.New('Mesh')
CircObj.link(CircMesh)
ThisScene = Scene.getCurrent()
ThisScene.link(CircObj)
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
Thanx in advance
Happy coding
How do I create a triangle in python?
Moderators: jesterKing, stiv