IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
basic_geometry.py
1
## \example display/basic_geometry.py
2
## This example shows how to write basic geometric primitives to a file with color and name.
3
4
import
IMP.display
5
6
# or IMP.display.ChimeraWriter
7
# if using chimera, make sure there is a %1% in the name to support multiple frames
8
name=IMP.create_temporary_file_name(
"example"
,
".py"
)
9
print
"File name is"
, name
10
w=
IMP.display.PymolWriter
(name)
11
12
bb=
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0,0,0),
13
IMP.algebra.Vector3D
(100, 100, 100))
14
# we could skip the outer loop if we only have one frame
15
for
f
in
range(0,10):
16
w.set_frame(f)
17
g=
IMP.display.BoundingBoxGeometry
(bb)
18
g.set_name(
"bb"
)
19
w.add_geometry(g)
20
for
i
in
range(0,10):
21
p=
IMP.algebra.get_random_vector_in
(bb)
22
g=
IMP.display.SphereGeometry
(
IMP.algebra.Sphere3D
(p, 10))
23
# give each a distinctive color
24
g.set_color(
IMP.display.get_display_color
(i))
25
g.set_name(str(i))
26
# add it to the file
27
w.add_geometry(g)