I want to refactor a VB program into ExtendScript to automate some drawing in Adobe Illustrator CS4, but have a requirement to read from a database. Is it possible to read from a database using ExtendScript? How?
My understanding is that you would need to use ExtendScript to 'doScript()' with your VB code. ExtendScript doesn't have any real database connection of its own. But I'm familiar with people that have VB code to connect to databases and return results. ExtendScript has that doScript method to run the VB code. The trick, it seams, is to find a way to get the data back to ExtendScript to tell the Adobe applications what to do. .doScript doesn't, to my knowledge, have a nice way to accept the results of the embedded code. So what I've heard people do is one of several things:
- Have the VB code write a text file that the ExtendScript code can read and parse.
- Have the VB code add a 'ScriptLabel' to your Adobe Illustrator document. Then use ExtendScript to read that same label. This is really the same as writing a text file, but there just isn't a file.
HTH
Jon S. Winters, ExtendScript Support, electronic publishing support
Illustrator scripting engine doesn't provided any mechanism to read external data directly, but you have several ways to do this...
- Write an external program which connecting database to generate VB script, and use Illustrator to exec the 'generated' script, which is the old way I have done.
- The new ScriptUI since cs3 provides to open a Window, containing a flash swf as a interface to drive Illustrator JS engine. You can read xml, call webservices, Flash Remoting inside flash content. I am not sure if you are comfortable to these toolsets.
I have a bit of a different solution I have been using successfully : Create a webservice that has access to your DB and then from ExtendScript use http connection to consume the services (and from there on you can do pretty much whatever you'd like).