Closed Luckp1089 closed 9 months ago
Hi @Luckp1089, currently you have to utilize the extra OpenBabel wasm module to enable the 2D layout of molecule. The following code may help your cause:
Kekule.OpenBabel.enable(function(error){ // load the extra OpenBabel.wasm module
if (!error)
{
// now the module has been succesfully loaded
const SiAtom = new Kekule.Atom('Si_Atom').setSymbol('C');
// ...
mol.appendNode(SiAtom);
// ...
// code to build molecule, but the coordinate settings can be omitted
// generate the 2D coordiates of atoms
const calculator = Kekule.Calculator.generateStructure(mol, Kekule.Calculator.Services.GEN2D, {modifySource: true},
function(generatedMol) {
console.log('Layout done');
}
);
}
});
This worked well, closing this issue. Thanks!!
Hi again!
When I modify a molecule by adding atoms to it, sometimes the bond angles come out looking a little strange. I was wondering if there was a way I could append Nodes and Bonds, and then recalculate the whole molecule so that it "redraws" it correctly? for reference, this is what my drawing looks like:
and here is a snippet of code that creates that drawing:
I am having trouble assigning the correct coordinates and was hoping for an easy way to just append Nodes and Connectors, and then redraw the whole molecule (this would be especially helpful when trying to draw rings as well):
I know that my current code assigns the coordinates but I was hoping for a way to populate "dummy" coordinates and have the drawer make the molecule look good. I have tried using mol.clean(); and mol.recalcCoords();, but these do not seem to change the structure of the molecule.
Thanks!