Edit2: I just realized that the bindings are already written. For my
question, I can use openbabel.doubleArray_frompointer(p) where p =
atom.OBAtom.GetCoordinate(). Sorry about not trying my best to search
before asking. Despite that, I hope this serves as a reference if someone
else encounter this problem.

There are other methods that are defined in openbabel.py that deal with
double arrays. One of them is documented here (
http://openbabel.org/docs/dev/UseTheLibrary/PythonDoc.html#calling-a-method-requiring-an-array-of-c-doubles).
Searching 'double' in openbabel.py should be enough to figure out the usage
of other similar methods.

Xianghai

On Fri, Aug 25, 2017 at 12:59 PM, Xianghai Sheng <xsh...@ucmerced.edu>
wrote:

> Edit: I'm aware of that atom.coords can get me the coordinates but this is
> just an example. Things like GetGradients doesn't have a easy binding in
> python. What I am asking is that is there a way to get double* data from
> C++ without writing new bindings?
>
> Xianghai
>
> On Fri, Aug 25, 2017 at 11:46 AM, Xianghai Sheng <xsh...@ucmerced.edu>
> wrote:
>
>> Hi,
>>
>> I need to get an atom's coordinate in a molecule in python. I tried
>> atom.OBAtom.GetCoordinate() but this function in openbabel returns a
>> double* (essentially an array) in C++ and there is no conversion for this
>> type in the python bindings afaik. As a result I just got type errors if I
>> try to get the values from the returned coordinate. How should I do this in
>> python?
>>
>> Thanks in advance!
>>
>> Xianghai Sheng
>>
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to