|
If you're new to Python A VPython tutorial Pictures of 3D objects Choose a 3D object: Work with 3D objects: Windows, Events, & Files: What's new in Visual 5 VPython web site |
Additional AttributesThe following attributes apply to all VPython objects: visible If False,
object is not displayed; e.g. ball.visible = False frame Place this object into a specified frame, as in ball = sphere(frame = f1) display When you start a VPython program, for convenience Visual creates a display window and names it scene. By default, objects you create go into that display window. You can choose to put an object in a different display like this: scene2 = display( title = "Act IV, Scene 2" ) Executing myscene = display.get_selected() returns a reference to the display in which objects are currently being created. Given a specific display named scene2, scene2.select() makes scene2 be the "selected display", so that objects will be drawn into scene2 by default. There is a rotate function for all objects other than curve, convex, faces, and points (which can be put into a frame and the frame rotated). __class__ Name of the class of object. For example, ball.__class__ is sphere is true if ball is a sphere object. There are two underscores before and after the word class. In a list of visible objects provided by scene.objects, if obj is in this list you can determine the class of the object with obj.__class__. You can check for a specific kind of object by using a standard Python function: isinstance(obj, sphere) is true if "obj" is a sphere object. __copy__() Makes a copy of an object. There are two underscores before and after copy. Without any arguments, this results in creating a second object in the exact same position as the first, which is probably not what you want. The __copy__() function takes a list of keyword=value argument pairs which are applied to the new object before making it visible. For example, to clone an object from one display to another, you would execute: new_object = old_object.__copy__( display=new_display). Restriction: If the original object is within a frame, and the new object is on a different display, you must supply both a new display and a new frame for the new object (the new frame may be None). This is due to the restriction that an object may not be located within a frame that is in a separate display. Here is an example that uses the __copy__() function. The following routine copies all of the Visual objects currently existing in one display into a previously defined second display, as long as there are no nested frames (frames within frames): def clone_universe( new_display, old_display): See Controlling One or More Visual Display Windows for more information on creating and manipulating display objects.
|
||