与 ExtendScript 一起使用数据库(适用于 Adob​​e Illustrator)

发布于 2024-07-16 10:57:04 字数 120 浏览 8 评论 0原文

我想将 VB 程序重构为 ExtendScript,以自动在 Adob​​e Illustrator CS4 中进行一些绘图,但需要从数据库中读取数据。 是否可以使用 ExtendScript 从数据库中读取数据? 如何?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

楠木可依 2024-07-23 10:57:04

是的,ES 可以读取 CSV。 只需使用逗号分隔格式化数据库即可。

这是一个应该可以解决问题的函数:

function readPref (thePath) {
    if (File(thePath).exists == true) {

    var file = File(thePath);
    file.open("r");
    file.encoding= 'BINARY';
    var theText = file.read();
    file.close();
    return String(theText).split(",")

    }
};

应该返回一个包含您需要的数组。 让 VB 导出一个数据库并用它来读取它。 多涅佐。

yeah, ES can read CSVs. just format your database using comma delineation.

here is a function that should do the trick:

function readPref (thePath) {
    if (File(thePath).exists == true) {

    var file = File(thePath);
    file.open("r");
    file.encoding= 'BINARY';
    var theText = file.read();
    file.close();
    return String(theText).split(",")

    }
};

should return an array with what you need. have VB export a database and just use that to read it. donezo.

落日海湾 2024-07-23 10:57:04

Illustrator脚本引擎没有提供任何直接读取外部数据的机制,但是您有几种方法可以做到这一点...

  1. 编写一个连接数据库的外部程序来生成VB脚本,并使用Illustrator来执行“生成”的脚本,这这是我做过的老方法。
  2. 自cs3以来新的ScriptUI提供了打开一个Window,包含一个flash swf作为驱动Illustrator JS引擎的接口。 您可以在 Flash 内容中读取 xml、调用 Web 服务、Flash Remoting。 我不确定您是否对这些工具集感到满意。

Illustrator scripting engine doesn't provided any mechanism to read external data directly, but you have several ways to do this...

  1. 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.
  2. 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.
×眷恋的温暖 2024-07-23 10:57:04

我已经成功使用了一些不同的解决方案:
创建一个可以访问您的数据库的 Web 服务,然后从 ExtendScript 使用 http 连接来使用服务(从那里开始您几乎可以做任何您想做的事情)。

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).

花落人断肠 2024-07-23 10:57:04

我的理解是,您需要在 VB 代码中使用 ExtendScript 来“doScript()”。 ExtendScript 本身没有任何真正的数据库连接。 但我熟悉有 VB 代码来连接数据库并返回结果的人。 ExtendScript 有 doScript 方法来运行 VB 代码。 看起来,诀窍是找到一种方法将数据返回到 ExtendScript,以告诉 Adob​​e 应用程序要做什么。 据我所知,.doScript 没有一个很好的方法来接受嵌入代码的结果。 因此,我听说人们所做的是以下几件事之一:

  • 让 VB 代码编写一个 ExtendScript 代码可以读取和解析的文本文件。
  • 让 VB 代码将“ScriptLabel”添加到您的 Adob​​e Illustrator 文档中。 然后使用 ExtendScript 读取相同的标签。 这实际上与编写文本文件相同,但只是没有文件。

乔恩·S·温特斯(HTH

Jon S. Winters),
扩展脚本支持,
电子出版支持

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

恋竹姑娘 2024-07-23 10:57:04

无论您是否需要将 VB 重构为 100% ExtendScript(没有 VB 代码,全部是 ExtendScript),我想说最简单的解决方案是这样的:

拥有一个调用 ExtendScript 的 VB/VBScript 包装器,并且该包装器处理数据库交互和将数据传回& 转到 ExtendScript。 这使您可以重用 VB 中的代码来保持数据库代码简单,并保持 ExtendScript 简单。

您可以使用 Adob​​e 应用程序的 COM API 从 VB/VBScript 调用 ExtendScript,该 API 具有从 ExtendScript 获得的所有绘图方法以及用于执行 javascript(或更实际的 ExtendScript)代码的 doJavascript() 方法。 同样的 doJavascript() 方法可用于引入 ExtendScript JSX 文件,而不是 JavaScript 代码片段。 您可以在相关的 SO 帖子中找到更多详细信息:

是可以从外部 ExtendScript 执行 JSX 脚本吗?

查看 Windows 特定的答案。 回答这个问题& 解决方案进一步,它也可以适用于其他平台(Mac、Python、Perl 等),它不必适用于 VB 和 Windows,相同的方法可以用于通过 Windows 上的 COM 或 Applescript 与外部 ExtendScript 交互Mac,并且可以与 COM/Applescript 兼容(或接口)的任何语言一起使用。

Whether or not you need to refactor VB to ExtendScript 100% (no VB code, all ExtendScript), I would say the simplest solution is something like this:

Have a VB/VBScript wrapper that calls ExtendScript, and this wrapper handles the database interaction and passes the data back & forth to ExtendScript. This allows you to keep the database code simple reusing what you have in VB and keep the ExtendScript simple.

You can call ExtendScript from VB/VBScript using the Adobe app's COM API, which has all the methods for drawing that you get from ExtendScript plus doJavascript() method for executing javascript (or more realistically ExtendScript) code. This same doJavascript() method can be used to pull in ExtendScript JSX files rather than a snippet of javscript code. You can find more details in a related SO post:

Is it possible to execute JSX scripts from outside ExtendScript?

look at the answers that are Windows specific. Taking this question & solution further it can work for other platforms as well (Mac, Python, Perl, etc.) it doesn't have to be for VB and Windows, the same approach can be used to interact with ExtendScript externally via COM on Windows or Applescript on Mac, and that will work with any language that is COM/Applescript compatible (or interfacing).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文