editor.struct().bonds - Get Bond List

Q

How to get a list of bonds currently in the Ketcher editor with the editor.struct().bonds property?

✍: FYIcenter.com

A

If you want to get a list of bonds currently in the Ketcher editor, you can use the editor.struct().bonds property on the Ketcher Editor interface.

Here is an HTML document that shows you how to get a list of bonds in Ketcher editor and print detailed information of the fist bond.

<html>
<!-- editor-get-first-bond.html Copyright (c) FYIcenter.com. -->
<head>
<title>Get the First Bond from Editor</title>
</head>
<body>
<p>Create a molecule structure, then click generate button below the editor:</p>
<iframe id=frmKetcher src="/ketcher/index.html"
  style="width: 680px; height: 400px;"></iframe>

<p><button onclick="generate();">Get the First Bond</button></p>
<p>Output:</p>
<pre id=output style="background-color: #ddd;"></pre>
<script>
  var ketcher = null;
  var display = document.getElementById("output");

function generate() {
  frm = document.getElementById("frmKetcher");
  ketcher = frm.contentWindow.ketcher;
  editor = ketcher.editor;
  structure = editor.struct();
  bonds = structure.bonds.entries();
  first = bonds.next().value;
  display.innerHTML = JSON.stringify(first, undefined, 2);
}
</script>
</body>
</html>

Open the above HTML document on your local Web server. Draw a benzene molecule in the editor.

Click "Get the First Bond" button, you will see that detailed information of the first bond of the structure in the editor is displayed.

[
  0,
  {
    "begin": 2,
    "end": 0,
    "type": 2,
    "xxx": "   ",
    "stereo": 0,
    "topology": 0,
    "reactingCenterStatus": 0,
    "cip": null,
    "len": 40.028581715494084,
    "sb": 10,
    "sa": 16.014290857747042,
    "angle": 150.01650970082835,
    "center": {
      "x": 1.2432867229912992,
      "y": 0.5500640451937939,
      "z": 0
    },
    "hb1": 0,
    "hb2": 1
  }
]

 

editor.struct().loops - Get Loop List

editor.struct().atoms - Get Atom List

Ketcher Editor Interface

⇑⇑ Ketcher - Chemical Structure Editor

2023-12-01, 235🔥, 0💬