schrodinger.graphics3d.common module

Utility functions for the graphics3d package.

The common module contains functions commonly used by the graphics3d modules. This includes the Group class, which is one clients use as a container for actual drawing primitive instances (like Arrow, etc.). See the Group class’ docstring for more details.

This code will automatically keep track of and handle each instance that is added to a Group instance. For information on how to create a Group and add intances to the Group, see the class docstring for Group and the method docstring for Group’s add() method, respectively.

Copyright Schrodinger, LLC. All rights reserved.


Calculate and return normalized vector.


v: List containing 3 floating values of x, y, z


List of 3 floating values reprsenting the normalized vector.

schrodinger.graphics3d.common.get_cross(v, w)

Get the cross product of v and w

Return type

[float, floatg, float]


Method to create a normal for the polygon defined by specified vertices.

vertices: List of floating value lists of [x, y, z] representing

a vertex.


List of 3 floating values representing the normal

FIXME: We use only the first three vertices to calculate the normal

and currently ignore the rest. Other vertices won’t matter if all the vectors are in a plane, which is going to the be case most of the time.


Returns a tuple of (r, g, b) [range 0.0-1.0 inclusive for each].


colorarg: Can be one of the following types -

Color: Color object instance string: Color name integer: Color index

class schrodinger.graphics3d.common.Primitive(maestro_objects=[])

Bases: object

All 3D objects derive from this class.


Hide the object. It will not be drawn when the group is drawn.


Display this object, if it was hidden


Called when the group of this object is hidden. Hide the Maestro object(s).


Called when the group of this object is shown. Show the Maestro object, if we are being shown.


Returns True if this object shown. False otherwise.


Returns True if this object’s group is shown. False otherwise.


Sets entry ID for Maestro object (necessary to render in tile-by-entry mode.


entry_id (str) – Object’s entry ID.

setRightClickOnGObject(pymodule, pyfunc)

Sets the python callback which should be called whenever given graphics object is right clicked.

  • pymodule (str) – Python module

  • pyfunc (str) – Python function


Enables or disables glow effect for the object.


is_glowing (bool) – Whether the object is glowing.

setGlowColor(r, g, b)

Sets glow color for the object.

  • r (float) – Red component of glow color [0.0 .. 1.0]

  • g (float) – Green component of glow color [0.0 .. 1.0]

  • b (float) – Blue component of glow color [0.0 .. 1.0]

class schrodinger.graphics3d.common.Group

Bases: object

Class to group a bunch of primitives and draw them out.

Example for non-Maestro objects:

my_box1 = box.Box(…) my_box2 = box.Box(…) my_sphere = sphere.Sphere(…)

my_group = box.Group() (or sphere.Group(), etc) my_group.add(my_box1) my_group.add(my_box2) my_group.add(my_sphere)


Constructor takes no arguments.


Return the number of primitives in this group. Note that each primitive type can have multiple instances registered and each of these is counted towards the total.


Return the number of unique primitive types in this group. This differs from the standard length operation. That returns a count of all primitive instances.


Do not draw objects belonging to this group. Will also modify Maestro’s bounding rect to exclude these objects.


Cancel effect of hide() method, and draw the objects belonging to this group. Will modify Maestro’s bounding rect to exclude these objects.


Returns True if this group is shown; False otherwise.


Add a drawing primitive instance (Box, etc.) to this group.


Remove a drawing primitive instance (Box, etc.) from this group.


Clear up drawing instances.


item_type – Can be one of the following: None, Arrow, Box, etc.


  • If item_type is None, all drawing instances will be removed; if item_type is not None, all drawing instances of the item_type class will be removed.

  • No effects if there is no drawing instances of the item_type class.

boundingBoxCallback(r00, r01, r02, r03, r10, r11, r12, r13, r20, r21, r22, r23, r30, r31, r32, r33)

Called when the workspace is fit to screen


Iterate through all the objects in this group and yield primitives.