Is it possible to get connectedObjs of Atom
agrodet opened this issue · 2 comments
Hello, and thank you again for this repository.
I have a simple question. Using Bond.connectedObjs
, we can know which Atom
are connected to a specific Bond
. I would like to do the reverse: from a selected Atom
, I would like to know the Bond
it is connected to.
Of course, by doing some algorithmic gymnastics, it is not so hard to go through all Bond
to find the ones connected to the currently selected Atom
. However, it is not very practical if one wants to "walk" the paths from the selected Atom
.
Is there any more direct way to go from Atom
to Bond
?
Hi @agrodet, you may use the atom.linkedConnectors
property to retrieve all connectors linking to this atom. Aside from normal bonds, other types of connector may be included in this property too. If only bonds should be considered, the getLinkedBonds
method can be used here:
let bonds = atom.getLinkedBonds(); // retrieve all bonds
let covalenceBonds = atom.getLinkedBonds(Kekule.BondType.COVALENT); // retrieve only covalent bonds
I see! I didn't find it in tutorials, and was looking for properties. Should have checked the methods as well 😄
Thank you very much! Awesome library.