First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.
What I’m trying to do
I am trying to pass a (SMILES) string to the CHEM plugin. I am not sure if this is a question for the creator of that plugin or a general issue with how I am passing the string.
I have tried passing a simple string to the plugin, which works:
smiles CCC=O / "
My problem comes when I try to pass a lookup from a table in the header (front matter) of the document:
where “= this.compound_properties[“ABCD-XXXXXXXX”].SMILES” by itself returns the correct SMILES string.
I am sure this is fairly basic, but the Chem plugin doesn’t like to be passed a variable by this method. Is there a way to force the result to be a string that Chem can recognize?
Thanks in advance!
Things I have tried
I’m having an educated guess that you’re experiencing some kind of race conditions, where the plugins do stuff in the wrong order for it to work as you expect it to.
The best way would be if the smiles plugin has an api to be called from dataviewjs. Another possible variant code be to use a Templater block to insert the smiles string as proper text (instead of the dynamic variant from dataview).
Yet another solution would be to make a
dv.view() which writes the smiles text to an intermediate file, which you then embed in the current document afterwards. That should also work.
It all comes down to which solution would work best in your scenario, and it’s a little dependent on how often you change the smiles string (and how many).
I think this is very helpful.
Yes - I think the issue is that the text generated from the dataview dynamic variant is not resolved before it is passed to Chem.
I am fairly new at this, but I think I can figure out how to address that, based on what you have suggested. I will add a comment if I get stuck (or if I solve this.)
PS - any other suggestions are also welcome.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.