Turbo
Turbo

Reputation: 323

Making cylinders in python?

I am trying to make a cylinder in Python 3.3.2 using the following code:

rod = cylinder(pos=(0,2,1), axis=(5,0,0), radius=1)
rod.pos = (15,11,9) # change (x,y,z)
rod.x = 15 # only change pos.x
rod.color = (0,0,1) # make rod be blue
rod.red = 0.4

With help from this site: http://www.vpython.org/contents/docs_vp5/visual/cylinder.html

The output is: NameError: name 'cylinder' is not defined

Is there anything I need to install or must I import something?

Thanks in advance

Upvotes: 2

Views: 3780

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1123260

You need to import cylinder from the visual module before you can use it in your module:

from visual import cylinder

The vpython tutorial imports everything in one go from that module with the syntax:

from visual import *

This all assumes you are using the VPython IDE, downloaded from the project website.

Upvotes: 3

Related Questions