CS 1 (Spring 2025) Project 04: VPython Object Attributes

VPython has a LOT of 3D objects that you can create, each with their own set of attributes that define their shape or other aspects. For instance, you can create an arrow, cone, curve, points and helix, to name a few.

To access the value of an attribute <attr> of a VPython object vp_obj of type <VPythonObject>, you just need to use vp_obj.<attr>. The attributes in VPython can also be included while instantiating the object in the first place, in the form of vp_obj = <VPythonObject>(<attr>=attr). A specific example is:

bob = sphere(pos=vector(0,1,1), color=color.cyan).

The ones we use in the Newton’s cradle are a sphere, cylinder and box. Here are a list of useful attributes for these objects!

sphere

box

cylinder

Additionally, all of the aforementioned objects have the following attributes too:

References:

  1. https://www.glowscript.org/docs/VPythonDocs/objects.html