Jump to content
Clutch Cargo

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
        }
        docRef.close(SaveOptions.SAVECHANGES);  
        }
    </Script>
    End Sub
Next

Share this post


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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×