Skip to main content
Inspiring
October 11, 2012
Answered

scripting via estk

  • October 11, 2012
  • 1 reply
  • 3885 views

Hello,

What i am trying to do is generate a jpg image from an ai file(not a drawing, but a library = not possible to open in pdf) shown in bridge.

I have my script, it is working correct when executing this in estk.

And if i understand correct, i need to create an object of illustrator in order to execute the script in my vb.net program. But, because this script has nothing to do with illustrator in general i was wondering if it is also posible to create an object of the estk program and execute the script in the background with this object instead of illustrator?

Thanks

Also another question:

When ran from vb.net, it goes in debug.

#target bridge

#targetengine "MainEngine"

function SnpCreateThumbInspectorPanel()

{

    try

    {

        this.requiredContext = "\tExecute against Bridge main engine.\nBridge must be running.";

        $.level = 1; // Debugging level

        this.panelRef = null;

       

        //alert(arguments[0]);

       

        Folder("c:\\temp\\illustratorcentraliser").create();

       

       //LINE 17 HERE

        var loc = new Thumbnail(Folder("/C"));

        loc.open();

       

        this.t = new Thumbnail(File("/c/00_sym.ai"));

        app.document.select(this.t);

     }

    catch(e) {

        alert( e + ":" + e.line );

    }

}

SnpCreateThumbInspectorPanel.prototype.run = function()

{

    if(!this.canRun())

    {

        return false;

    }

    var bmd = new BitmapData(this.t.spec);

    if(bmd instanceof BitmapData)

    {

        var expPath = "C:\\temp\\illustratorcentraliser\\" + this.t.name + ".jpg";

        bmd.exportTo(new File(expPath));

        return true;

    }

    $.writeln("ERROR:: Cannot render thumb");

    return false;

}

SnpCreateThumbInspectorPanel.prototype.canRun = function()

{

    if(BridgeTalk.appName == "bridge") { return true; }

    $.writeln("ERROR:: Cannot render thumb");

    $.writeln(this.requiredContext);

    return false;

}

if(typeof(SnpCreateThumbInspectorPanel_unitTest)  == "undefined") {

    new SnpCreateThumbInspectorPanel().run();

}

it says

---------------------------

Script Alert

---------------------------

ReferenceError: Thumbnail does not have a constructor:17

---------------------------

OK  

---------------------------

the code i am using in vb.net is

dim illy as illustrator.application = CreateObject("Illustrator.Application")

illy.DoJavaScriptFile("C:\previewSelectedLibrary.jsx")

Message was edited by: abjelly

This topic has been closed for replies.
Correct answer Muppet Mark

You can not run a Bridge script from another application, but what you can do is use BridgeTalk to talk to Bridge from another Application.


Paul, you would use bridgetalk if using extendscript to communicate between apps… Im unsure on vb.net but with AppleScript I can use the command do javascript in AI, BR, ID & PS AppleScript holds all the data to transfer between apps. The do javascript command will take string or file as argument… Its just the same as running a javascript snippet in the host app…

abjelly, yes AI has a do javascript like I just mentioned to Paul… What you need to understand is each app has it's own object model and only the core javascript is shared… So you can't use Bridge syntax in Illustrator the classes just don't exist. A bridge script must be run in bridge… same for each of the other apps… There is nothing in your script that uses any particular feature/command related to AI.

AI does NOT have new Thumbnail(), new BitmapData()…

1 reply

Inspiring
October 11, 2012

I have no idea about vb.net but the posted snippet is a bridge script so it will only run in bridge… Illustrator has NO idea what a thumbnail is the class ONLY belongs to bridge… I can only suggest is you replace references of Illustrator for Bridge… The fact that the file was created by Illustrator is irrelevant…

If vb.net is similar to my macs AppleScript and you can pretty much only access doing javascript? Then you don't need 90% of whats posted in your sample script… The construct of the above is to unit test using the estk to run it… You possibly just want a couple of lines of text… that you can pass as argument or you can save in file and pass the file…?

abjellyAuthor
Inspiring
October 11, 2012

Hello Muppet Mark. Thanks you for your response

My purpose is to extract a jpg file from a illustrator symbols library via bridge because bridge is the only adobe program that generates a thumbnail view about it.

And as i understand, you need for example illustrator to execute the script against bridge because you cannot access bridge programatically.

So what i do is import the illustrator COM object in my visual studio program so i can access it's functions.

Thats why i write

dim illy as illustrator.application = CreateObject("Illustrator.Application")

illy.DoJavaScriptFile("C:\previewSelectedLibrary.jsx")

Dojavascriptfile is actually a function in the illustrator library which runs the script.

But the script gives An error that Thumbnail does not have a constructor, even if my script code is the same as in the SDK pdf.

I do not understand.

Paul Riggott
Inspiring
October 11, 2012

You can not run a Bridge script from another application, but what you can do is use BridgeTalk to talk to Bridge from another Application.