Jump to content

Add JavaScript inside Vscript

Recommended Posts

I am trying to add some JS code inside my vbscript.  I know literally nothing regarding JS so what I have researched I have come up with this but I get a "syntax error" at  the 'Sub Trace()' line.

Can anyone show me the proper way?

Set App = CreateObject("Illustrator.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FSO.GetFolder("S:\SOCAL\Section_31\buildCOM TIFFs")
Set TIFFfile = SourceFolder.Files

Dim FileRef
For Each FileRef In SourceFolder.Files
    Set AutoCADOpenOptions = App.Preferences.AutoCADFileOptions
        AutoCADOpenOptions.MergeLayers = false
        CurrentInteractionLevel = App.UserInteractionLevel
        App.UserInteractionLevel = -1 ' aiDontDisplayAlerts
        Set myDoc = App.Open(FileRef.Path,2)
        App.UserInteractionLevel = CurrentInteractionLevel
    Call Trace()
    Sub Trace()
    <Script Language="JavaScript">
    function traceRaster(){
        var docRef = App.ActiveDocument;  
        for(var a=0;a<docRef.placedItems.length;a++){  
            //this script implies the images are LINKED, not embedded. if you are working with embedded images, change 'placedItems' to 'rasterItems'
        var item = docRef.placedItems[a];
        var traced = item.trace();  
            traced.tracing.tracingOptions.loadFromPreset("Land Cover");  
            //Change 'Line Art' or your preferred tracing preset if necessary
    End Sub

Link to post
Share on other sites

Those are 2 different languages, you can't mix them.  They cannot share variables or anything like that.  You're better off choosing a language and converting whatever code you need to convert to that language.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...