That solves the problem -- thank you! Best regards,
Peng On Fri, Apr 8, 2016 at 6:05 AM, Andreas Kempe <a.ke...@isd.uni-hannover.de> wrote: > The problem seems to be related to the internal coordinate pointers not > being initialized correctly. > I suggest forcing a manual update after changing the molecule: > > import openbabel as ob > obmol = ob.OBMol() > obmol.BeginModify() > obatom = obmol.NewAtom() > obatom.SetAtomicNum(6) > obatom.SetVector(1.0, 1.0, 1.0) > obmol.EndModify() > obmol.AddHydrogens() > obatom2 = obmol.GetAtom(2) > print obatom2.GetX() > > -------- Original-Nachricht -------- > Betreff: [Open Babel] AddHydrogens() and subsequent GetX() causes > segmentation fault > Von: Peng Bai <peng...@umn.edu> > An: openbabel-discuss@lists.sourceforge.net > Datum: 07.04.2016 18:30 > > Dear OpenBabel users, > > I wanted to use the AddHydrogens() method from Python, and things work > fine if I create an OBMol object by reading in a file, but it crashes > with a segmentation fault if I used it as in the example below. I > tried it on different machines: > > (1) Python 2.7.9 > OpenBabel git:d56a5d compiled with gcc 5.1.0 > or OpenBabel 2.3.2 compiled with gcc 4.9.2 > (2) Python 2.7.10 > OpenBabel git:d56a5d > compiled with gcc 4.8 > > An example interactive session: > > ~~~ > In [1]: import openbabel as ob > In [2]: obmol = ob.OBMol() > In [3]: obatom = obmol.NewAtom() > In [4]: obatom.SetAtomicNum(6) > In [5]: obatom.SetVector(1.0, 1.0, 1.0) > In [6]: obmol.NumAtoms() > Out[6]: 1 > In [7]: obmol.AddHydrogens() > Out[7]: True > In [8]: obmol.NumAtoms() > Out[8]: 5 > In [9]: obatom2 = obmol.GetAtom(2) > In [10]: obatom2.GetAtomicNum() > Out[10]: 1 > In [11]: obatom2.GetAtomicMass() > Out[11]: 1.00794 > In [12]: obatom2.GetX() > Segmentation fault > ~~~ > > Any suggestions why this may happen? Thanks very much in advance! > > Best regards, > > Peng > > ------------------------------------------------------------------------------ > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > > ------------------------------------------------------------------------------ Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! http://pubads.g.doubleclick.net/ gampad/clk?id=1444514301&iu=/ca-pub-7940484522588532 _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss