# How do I print property matrices in Avogadro?

I'd like to print the content of property matrices (i.e., the matrices shown after selecting View→Properties→X where X is one of the six options shown, including Angle properties..., Atom properties... and Bond properties...) in Avogadro, but I can't seem to find this option at Avogadro Wiki or other forms of Avogadro documentation.

e.g. this is the bond properties matrix.

• Right, it doesn't exist at the moment. Probably the easiest thing would be to allow export as text or a CSV, but I'm not sure when the next release would be. – Geoff Hutchison May 4 '15 at 15:14
• I'd also like to recommend future releases include a Windows version with python terminal as the only way I can access the python terminal is via installing Avogadro 1.0.1 python win32 (i.e., the file available here internode.dl.sourceforge.net/project/avogadro/avogadro/1.0.1/…). – Josh Pinto May 4 '15 at 23:05
• Yes, but without a Windows developer, those releases will be something of second-class citizens to Mac and Linux releases, sorry. – Geoff Hutchison May 5 '15 at 4:18

I am not aware of a menu button to print these tables.

There is however a different way to get your hands on the numbers.

Avogadro features objects: molecules, bonds and atoms are instances of classes, whose properties can be read and processed by programming. The easiest way is the build-in Python-Terminal.

1. In Avogadro, open a Python Terminal (In German, this is done via
Einstellungen -> Werkzeugleisten -> Python-Terminal, which should be something like Settings -> Tool bars -> Python terminal

When run in the Python terminal of Avogradro, the following snippet writes

• atom index
• atomic number
• x, y, z coordinates

for all atoms of the currently opened molecule to a csv file into an existing tmp directory in the user's home.

import os.path
import csv

home = os.path.expanduser('~')
data_dir = 'tmp'
atom_table_name = 'atoms.csv'
atom_table_path = os.path.join(home, data_dir, atom_table_name)
# generate full path for file with atom data

with open(atom_table_path, 'wt') as fout:
writer = csv.writer(fout)
writer.writerow(('Index', 'Atomic number', 'X', 'Y', 'Z'))

for atom in mol.atoms:
index = atom.index + 1
x, y, z = atom.pos
writer.writerow((index, atom.atomicNumber, x, y, z))


EDIT

I mentioned the Python Terminal first because I didn't want to introduce too much different things at once.

Once you have played a bit with the build-in Python Terminal, you will want to go one step beyond and try a more comfortable IDE with logging, tab-completion, build-in help, etc. My suggestion is to try IPython!

With IPython (or any other IDE of your choice), you can make use of Avogadro through its API without actually running it.

Given that your data file propen.cml looks like this:

<molecule> <atomArray> <atom id="a1" elementType="C" x3="-6.736896" y3="1.198243" z3="-0.001854"/> <atom id="a2" elementType="C" x3="-5.625957" y3="2.233390" z3="-0.108371"/> <atom id="a3" elementType="H" x3="-6.748313" y3="0.730420" z3="0.988429"/> <atom id="a4" elementType="H" x3="-6.615420" y3="0.408802" z3="-0.751312"/> <atom id="a5" elementType="H" x3="-7.710837" y3="1.671184" z3="-0.163704"/> <atom id="a6" elementType="C" x3="-4.268024" y3="1.629800" z3="0.106393"/> <atom id="a7" elementType="H" x3="-5.801148" y3="3.017025" z3="0.637857"/> <atom id="a8" elementType="H" x3="-5.668681" y3="2.695849" z3="-1.101309"/> <atom id="a9" elementType="C" x3="-3.137190" y3="2.345874" z3="0.062502"/> <atom id="a10" elementType="H" x3="-4.203709" y3="0.562202" z3="0.306350"/> <atom id="a11" elementType="H" x3="-3.147760" y3="3.413685" z3="-0.133506"/> <atom id="a12" elementType="H" x3="-2.172936" y3="1.873521" z3="0.222912"/> </atomArray> <bondArray> <bond atomRefs2="a1 a2" order="1"/> <bond atomRefs2="a1 a3" order="1"/> <bond atomRefs2="a1 a4" order="1"/> <bond atomRefs2="a1 a5" order="1"/> <bond atomRefs2="a2 a6" order="1"/> <bond atomRefs2="a2 a7" order="1"/> <bond atomRefs2="a2 a8" order="1"/> <bond atomRefs2="a6 a9" order="2"/> <bond atomRefs2="a6 a10" order="1"/> <bond atomRefs2="a9 a11" order="1"/> <bond atomRefs2="a9 a12" order="1"/> </bondArray> </molecule>

you can load the CML file and iterate over the bonds to display the index numbers of the atoms in the bond and the bond length using:

import Avogadro as av


• That gave the output: Traceback (most recent call last): File "<string>", line 1, in <module> IOError: [Errno 2] No such file or directory: 'C:\\Users\\Brenton\\tmp\\atoms.csv' – Josh Pinto May 4 '15 at 10:47
• @BrentonHorne Does a tmp directory exist in your home? – Klaus-Dieter Warzecha May 4 '15 at 11:00
• @BrentonHorne I'm sorry for the confusion. I just haven't made myself clear enough :) I wanted to avoid that your home folder gets littered up with stuff. Therefore, the code snippet was programmed to write the csv to a separate directory, tmp for all the temporary stuff that can be deleted later. If you create the tmp directory manually, the script - run from within Avogadro - should work as intended :) – Klaus-Dieter Warzecha May 4 '15 at 12:34
• Thanks, but it appears that Avogadro still wants to be difficult, and is giving me this output: Traceback (most recent call last): File "<string>", line 5, in <module> NameError: name 'Avogadro' is not defined – Josh Pinto May 4 '15 at 12:38