Preparing Eisenscript for the XML Translator

I mentioned in the Translating Nabla post that I’ve been using Elfnor‘s Eisenscript-to-XML python script to quickly translate Structure Synth Eisenscript files into the XML format needed for the Sverchok Generative Art node.

After various attempts, I’ve come up with a set of rules to prepare a Structure Synth Eisenscript for the XML translator to avoid the dreaded, “I don’t understand the eisenscript” message.

  • Remove any ‘//’ comments
  • Remove any colour, background and raytracer references. (I think the parser simply ignores these, but I remove them anyway).
  • Check for non-integer rule weights – e.g. ‘rule mybox w 0.5’ – I would multiply all rules weights by 10 here. Again, the parser doesn’t mind these, but the GA nodes does so I try catch them here.
  • Insert holding text in empty rules – I’ve found the parser does not process any rules after an empty one. My solution is to insert some holding text into empty rules which can easily be ‘search and replaced’ in the XML result.
For example:
rule stop { 

}

becomes

 rule { 

   HoldingText 

 }

which becomes

<rule name="stop">
   <!-- Do Nothing -->
</rule>

in the final XML version after a search and replace on ‘HoldingText’.

In the XML translation, I also remove the <?xml version=”1.0″ ?> top line as the Sverchok GA node doesn’t seem to like it. I also go back through and reinstate any comments using the HTML/XML comment format:

<!-- Comment text -->

I use comment text at the top of the script to keep a note of the source of the original script so I can credit and link back to the person who kindly shared their script with the world.

Update: It seems the “max_depth” rule is a requirement in the opening rules tag:

<rules max_depth="400">

And let’s not mention how much time I’ve lost tonight before I realised that rule names are case-sensitive.

 

Comments are closed.