Guest

## How do I create a triangle in python?

#### truenoeks

Posted: Wed May 28, 2003 7:24 pm
Joined: 16 Oct 2002
Posts: 8
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):

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

Happy coding

 Jump to: Select a forum Blender development forums----------------User Questions that really belong on blenderartists.orgNews & ChatCoding BlenderDocumentation & EducationFoundation and WebsitesTesting BuildsBlender Open ProjectsBlender Conference 2013Academic & Research Blender functionality forums----------------Interface & ToolsAnimationRenderingPythonInteractive 3d