Ticket #1470: test_map.py

File test_map.py, 639 bytes (added by Tom Goddard, 4 years ago)

Example Python script using ChimeraX wheel to open map, save gltf, save image.

Line 
1# Create session
2from chimerax.core.session import Session
3session = Session('cx standalone', offscreen_rendering = True)
4
5# Open map
6from chimerax.map import open_map
7from os.path import expanduser
8models, msg = open_map(session, expanduser('~/Downloads/ChimeraX/EMDB/emd_1080.map'))
9session.models.add(models)
10
11# Compute surfaces
12for v in models:
13 print ('opened map', v, 'size', v.data.size)
14 v.update_drawings() # Compute surface
15
16# Write GLTF file of map surface
17from chimerax.gltf import write_gltf
18write_gltf(session, 'test.glb')
19
20# Save an image
21from chimerax.image_formats import save_image
22save_image(session, 'test.png')