Script UI interrupts the connection with the AI Document?

Last week, I wrote a simple script that interacts with my document and export layers as images.

The script works fine, but I thought I would add a UI nice to it until I have communicated to the world, so I spent last Saturday with the GUI.

Now, I've built my UI, and I connect to my existing code.

If I trace the current "activeDocument" at the beginning of my code before I instantiated the window, I get what you expect:

Alert ("Current Window:"+.app.activeDocument);// Traces - active window: [Document myTestDoc.ai] ")

Now, if I try my reference document since the window click handler, or after I closed my window I get this:

Alert ("Current Window:"+.app.activeDocument);// Traces - active window: [Document] ")

Alert ("current Window:"+.app.documents[0]);// also Traces - active window: [Document] ")

The script can still see the document, but suddenly he can't introspect it.

"app.documents" gives the right number of open documents.

'app.name' gives the correct application "Adobe Illustrator"

but something like the following will fail.

Alert(App.documents[0].layers.) Length);

Any advice would be massively appreciated.

Thank you

-J

cool, maybe we find a simple as a possible solution.

you don't need the alert, you must set to start:

#targetengine? (I've heard "non-main" but this seems to be not true, it can be main?)

don't ask me why

#target illustrator
#targetengine another

var btnPnlResource ="panel { orientation:'row', \
text: 'Push Button to Test', \
testBtn: Button { text:'Test' }, \
}";
var dlg = new Window("palette", "Select PATH");
dlg.btnPnl = dlg.add(btnPnlResource);
dlg.show();
dlg.btnPnl.testBtn.onClick = traceDoc;
//alert("Move me, don't close me.");
function traceDoc(){
    // !!!!!!!!   dlg.close(1);
    var myFile = new File("~/Desktop/test2.jsx");
     var content= "#target illustrator\n" +
     "#targetengine another\n" +
    "alert('Written from script1: AREA:'+app.activeDocument.selection[0].area)";
    myFile.open("w");
    myFile.write(content);
    myFile.close();
    myFile.execute();
// !!!!!!!dlg.show() // !!!!!!!!!!!!!!!
 }

problem is the estk asks 'do' and need time to react.

faster, but only for windows:

(test2.jsx still exists)

#target illustrator
#targetengine another

var appPath = app.path + "/Support%20Files/Contents/Windows/illustrator.exe " ;//unix?
var shellScriptPath = "~/desktop/AiShellScript.bat" ;
var aiScriptPath = "~/desktop/test2.jsx" ;

function Schell(){
     var ssp = new File( shellScriptPath ) ;
     ssp.open("w") ;
     var tex = "@echo off\n"+   // unix?
          "Start \"\" \"" + File(appPath).fsName + "\" " + File(aiScriptPath).fsName + "\"" ;  //unix?
     ssp.write( tex ) ;
     ssp.close() ; ssp = null ;
}

var btnPnlResource ="panel { orientation:'row', \
text: 'Push Button to Test', \
testBtn: Button { text:'Test' }, \
}";
var dlg = new Window("palette", "Select PATH");
dlg.btnPnl = dlg.add(btnPnlResource);
dlg.show();
dlg.btnPnl.testBtn.onClick = traceDoc;
function traceDoc(){
     Schell();
     var myFile = new File( shellScriptPath );
     myFile.execute();
}

but, that never, interesting case is

-We don't need to close the window.

-We can run script then 1 more

-that we cannot examine the variables between scripts, even if targetengine (declared) is identical in the two scripts, I think that this is not really the same thing.

Edit: It IS perhaps all THE NONSENSE, because:

illustrator12. ExecuteScript (myAIScript);

but it seems that illustrator can not be it's own targetapplication?

     try{
     illustrator.executeScript( "~/desktop/test2.jsx" );
     }catch(e){alert(e)}

It gives me a syntax error

Tags: Illustrator

Similar Questions

  • Need a little help. Script to export the single document for different types of files.

    Hey guys, I'm new to scripting. have looked everywhere but cannot find an answer to this, I'm sure it's pretty simple


    At work we export logos all the time in a few different formats for the clients.
    I looked in the script as a way to automate the process.

    So far, I thought a little script to export my Illustrator formats document... now I need to be able to export this document even outside as a res low and high PNG, low and high res JPEG, EPS, PDF and TIFF etc.
    I have scripts to do all these separately but just need to know how to put it all in a single script I can do all at once

    Here is an example of my two different scripts to export PNG. I just need to know how string together so I can add all of the formats without breaking it.

    function savePNG() {}
    var destFolder = Folder.selectDialog ("select the folder to export the PNG files to :');")
    If {(destFolder)
    If (app.documents.length > 0) {}
    var Nomdoc = app.activeDocument.name.match(/^.*[^.ai]/i);
    var destFile = new file (destFolder + ' /' + Nomdoc + "-HR.png");
    if(destFile == null) {return ;}
    var doc = app.activeDocument;
    var artRect = doc.artboards [0] .artboardRect;
    var exportOptions = new ImageCaptureOptions;
    exportOptions.resolution = 300;
    exportOptions.antiAliasing = true;
    exportOptions.transparency = true;
    doc.imageCapture (destFile, artRect, exportOptions);
    }
    }
    }
    savePNG();

    and here is the version low resolution

    function savePNG() {}
    var destFolder = Folder.selectDialog ("select the folder to export the PNG files to :');")
    If {(destFolder)
    If (app.documents.length > 0) {}
    var Nomdoc = app.activeDocument.name.match(/^.*[^.ai]/i);
    var destFile = new file (destFolder + ' /' + Nomdoc + "-LR.png");
    if(destFile == null) {return ;}
    var doc = app.activeDocument;
    var artRect = doc.artboards [0] .artboardRect;
    var exportOptions = new ImageCaptureOptions;
    exportOptions.resolution = 72;
    exportOptions.antiAliasing = true;
    exportOptions.transparency = true;
    doc.imageCapture (destFile, artRect, exportOptions);
    }
    }
    }
    savePNG();

    Thanks for any advice you can give!
    Eli

    Oh, you want to perform two functions, one after another at the same time? then just name with different names and perform one function after another, if all files will be saved in the same folder, the argument selectDialog move method on each of your functions to don't do only once.

    function savePNG_HR(){
        var destFolder = Folder.selectDialog('Select the folder to export the PNG files to:');
        if (destFolder) {
            if(app.documents.length > 0){
                var docName = app.activeDocument.name.match(/^.*[^.ai]/i);
                var destFile = new File(destFolder + '/' + docName + " - HR.png");
                if(destFile == null){return;}
                var doc = app.activeDocument;
                var artRect = doc.artboards[0].artboardRect;
                var exportOptions = new ImageCaptureOptions;
                exportOptions.resolution = 300;
                exportOptions.antiAliasing = true;
                exportOptions.transparency = true;
                doc.imageCapture(destFile, artRect, exportOptions);
            }
        }
    }
    
    function savePNG_LR(){
        var destFolder = Folder.selectDialog('Select the folder to export the PNG files to:');
        if (destFolder) {
            if(app.documents.length > 0){
                var docName = app.activeDocument.name.match(/^.*[^.ai]/i);
                var destFile = new File(destFolder + '/' + docName + " - LR.png");
                if(destFile == null){return;}
                var doc = app.activeDocument;
                var artRect = doc.artboards[0].artboardRect;
                var exportOptions = new ImageCaptureOptions;
                exportOptions.resolution = 72;
                exportOptions.antiAliasing = true;
                exportOptions.transparency = true;
                doc.imageCapture(destFile, artRect, exportOptions);
            }
        }
    }
    savePNG_HR();
    savePNG_LR();
    
  • Keyboard Slim lose the connection with the Dell coming 11 Pro

    Someone meets keyboard slim interruption of connection with the Dell pro 11 site?

    He might have to unplug the keyboard, and the re - attach the keyboard to the Tablet again to use the keyboard.

    I have two Dell 11 pro + keyboard slim venue. Both devices have this kind of problem.
    It's absolutely wrong.

    How to solve this problem?

    Besides working with Dell Pro they explained to me that the keyboard must be used on a flat surface (not towers for example) and the keyboard & tablet should be at an angle of about 117 degrees between them.  Now, of course, you can't measure it, so just assume if you use on a table or desk and its supported properly you have to the correct angle.

    I find that if the keyboard does not after sleep or start arriving, simply lift the keyboard out of the surface of the table a few inches and let it fall down.  It will immediately start working.   I think that there is a sensor in the keyboard, which is not always realize or to calibrate properly in coming to life.

    If you have complications beyond the keyboard chip out of sleep, I'd take it upward with the support to push the issue.

  • Close the active document without saving changes

    Hi all

    Someone at - it a script to close the current document of the acrobat form without saving changes?

    I have a script to do all the fields in a read-only form, print and then send the finished form, but would then close the document without saving changes.

    Thank you

    Simon

    this.closeDoc (true)

  • How to activate the connection with sqlplus / as sysdba?

    Hello

    I downloaded the virtual appliance of the developer day since that's Developer Day - hands-on data application development

    Connection with sqlplus sys/oracle as a sysdba work

    But for our scripts, I need to connect to sqlplus / as sysdba (os user's oracle).

    If I try to open a session with / as sysdba I get this:

    [oracle@localhost ~]$ sqlplus / as sysdba
    
    SQL*Plus: Release 12.1.0.2.0 Production on Tue Nov 3 02:13:34 2015
    
    Copyright (c) 1982, 2014, Oracle.  All rights reserved.
    
    ERROR:
    ORA-01017: invalid username/password; logon denied
    
    
    Enter user-name: 
    

    How can I activate the oracle user to login with / as sysdba?

    Thank you

    Al

    It seems that I found the solution:

    http://www.stojanveselinovski.com/blog/2014/07/07/Oracle-12C-developer-days-VM/

    Very funny this TWO_TASK / ORACLE_SID. :-)

    CurrentY I can connect to sqlplus / as sysdba - I'm going to restore the virtual machine and try again if this is really the solution. :-)

  • Best way to configure MySQL connection scripts for hosts the remote and

    I'm curious to know if there is an effective way to do it.  I have my local MAMP server test, then a remote server, both with MySQL.  Pages requiring PHP and databases at the start with a link to my login script.  However, the connection to my local details vary my remote servers.  I have two login scripts and need to change the link of each page when I download, or have a login script and change it directly whenever I'm working between the two.

    How will people work effectively in environments the and remote?

    The login script does not have to be in your PHP pages. Not good security. It should be above the root of the Web site, where it is not accessible via http. The name of the file containing the script of the same for the remote and local, even if the content is different.

    Then your PHP pages call a file with the same name and you don't need to change anything.

    require_once '... /... / / here. Connection.php';

    Also note that the file name begins with a period that allows to hide.

  • Script to remove applied connects on the physics of the standby database

    Hello

    Our prod DB is configured with Dataguard physical standby Database (10.2.0.4) on Linux.

    I'm trying to write a script to delete the archives that are applied on a standby database to DR (standby server).

    Any help will be appreciated.

    Kind regards
    Viswa08

    viswa08 wrote:
    Hi pavan,.

    I received the script of OTN itself below is the script and I can't understand how the sequence is deleted.

    ******************************************************************************************
    ###################
    #! / usr/bin/ksh

    script = ' basename $0'.

    SID = RW2P
    dir = / u04/oracle / $sid/arch

    Prof = $HOME /'echo ${sid} | AWK ' {print tolower($0)} ".profile
    tmpf=$home/.$script.tmp

    LogCount = 100

    function GetAppliedLogfileSequenceNumber
    {
    sqlplus-s/nolog $tmpf
    Connect / as sysdba
    Go head
    set pages 0
    Select max(sequence#) from v$ archived_log in case of application = 'YES ';
    output
    EXPRESSIONS OF FOLKLORE
    return
    }

    If [f $prof]
    then
    . $prof
    on the other
    print ' $script: $prof no such file or directory ".
    Output 1
    FI
    If [d $dir]

    If there is the $dir

    then
    CD $dir

    change directory to $dir

    GetAppliedLogfileSequenceNumber

    call the GetAppliedLogfileSequenceNumber function

    So [s $tmpf]

    If there is no sequence max

    then
    Count ='cat $tmpf | AWK '{print $1} ' | SED 1 d; »

    Set as maxsequence

    If [${#count} - No 0]

    If the counter is not zero

    then
    Let count = $count - $logcount

    Assign County County-100 the script does not remove the last 100 archivelogs applied.

    If ((County<=>

    If count is less than or equal to zero

    then
    print ' $script: journal count is set to zero (or not) no or newspapers to remove.
    Exit 0
    FI
    on the other
    Exit 0
    FI
    on the other
    print ' $script: no archive or newspapers to remove.
    Exit 0
    FI
    While [http:// f ${sid} _arch_1_$ {number} .arc]

    If $ORACLE_SID_arch_1_count.arc is

    do
    RM-f ${sid} _arch_1_$ {number} .arc

    delete

    RCODE = $?

    RCODE is assigned as the return code of the rm command.

    If ((rcode! = 0))

    If the return code is success

    then
    Print "$script: can't delete: ${sid} _arch_1_$ {number} .arc.
    Output 1
    on the other
    Let count = $count - 1

    reduce the number of 1

    FI
    fact
    RM-f $tmpf

    delete the temporary file.

    on the other
    print ' $script: $dir no such file or directory ".
    Output 1
    FI
    Exit 0

    Hope will help you.

    Kind regards.

  • I just bought the last Apple TV - I can't seem to connect with the App Store and Siri is completely useless. This is an example of how Apple is unable to produce a useful product?

    I just bought the last Apple TV - I can't seem to connect with the App Store and Siri is completely useless. This is an example of how Apple is unable to produce a useful product?

    Hello

    Be sure to follow the instructions in this article to support > set up your Apple TV (4th generation) - Apple supported

  • Current device is registered with the former owners of Apple ID, not allow me to connect with my Apple ID?

    Current device is registered with the former owners of Apple ID, not allow me to connect with my Apple ID?

    The former owner must unlock with their password, or give you the password. Otherwise, the phone doesn't help you and no one can help you. Get your money back if you can.

    What to do before you sell or give away your iPhone, iPad or iPod touch - Apple Support

  • Mac book air cannot detect my iPhone 6, after the cable on my I phone 6 to connect with my mac book air, nothing appear on the mac book. Seems like it can't detect the file i phone 6. I want to export my photos and do the upgrade version.

    Hi, after plug the cable on my phone i 6 to connect with my mac book air, nothing appear on the mac book.

    Seems like it can't detect the file i phone 6. I want to export my photos and do the upgrade version.

    Current situation is nothing exportable phone and also cannot do anything mac book because they cannot detect each other. Please advise, thank you.

    You can try to move to a different USB port. And if your just trying to swap photos try Airdrop. Also try to go here If iTunes does not your iPad, iPhone or iPod - Apple SupportHope this help, good luck to you.

  • Thunderbird does not connect with the server

    Another recent problem is Thunderbird does not connect with the server. I don't know if sent mail will go out, but I know I'm nothing receive. My internet connection works well for FF or another browser. I checked my settings and they seem OK. I checked the default settings in Win10x64 and they are correct. Any ideas?

    Although windows 10 is new for us all. How do solve you. I have other solution with very similar issues.

  • Does not connect with the e-mail server after update.

    Thunderbird ran an auto update yesterday. Then it just stopped working. It does not connect with the Comcast email server. An error message appears "Unable to connect" and "the connection was refused when attempting to contact live.mozilla.messaging.com. I don't want to uninstall and reinstall for fear of losing my emails and address book. How can we get Thunderbird set, there is no tool in the toolbar to enable the debugging and correction of program errors.

    I use Thunderbird version 38.1.0.

    Thank you.

    The problem solved itself, Thunderbird has just started working. I followed the thread suggested by Christ1 and found none of it applied. No malware, no browser, no certificate error security block. I did, however, in Thunderbird, under Tools/Options/General uncheck the button for "When Thunderbird launches, show the Start Page in the message box." I do know that if this helped, Thunderbird still do not access Comcast mail for hours after that, even with several stops and restarts.

    Until the next problem...

  • 1st generation Apple TV cannot connect with the apple ID

    Have 1st Generation apple TV and recently cannot connect with my apple ID.

    The reset several times and nothing.

    Help?

    You have activated 2 no authorization of your Apple ID? If so, disable the connection from a browser and temporarily, then connecting ATV, then reactivate. If not, please describe what is happening when you try to connect. What message do you have?

  • should my time capsule be connected with a cable for backups, after the initial installation?

    should my time capsule be connected with a cable for backups, after the initial installation?

    If you mean that you have to keep your Mac connected to a Time Capsule via Ethernet for future backups, then the answer is no. Time Machine and time Capsule are designed to work over wireless for your Mac would just need to be connected to the wireless network provided by the time Capsule.

  • Once a day linking Bing itself forces on FireFox. He interrupts the connection.

    Once a day linking Bing itself forces on FireFox. He interrupts the connection.

    This is the link that is displayed: go.microsoft.com/fwlink/?LinkID=219472 & clcid = 0x409

    I get this message: the connection was reset

    The connection to the server was reset while the page is loading.

       The site could be temporarily unavailable or too busy. Try again in a few moments.
       If you are unable to load any pages, check your computer's network connection.
       If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
    

    Try again

    I don't use any of Bing. Only StartPage Qwant and DuckDuckGo.

    PS I also asked this question on the MS 8.1 Bing forum. As he might also be a Windows problem.

    Thank you very much.

    Ok. The only thing I forgot to do, is use Qwant to for a search on the link I provided. And now the answer has been:

    https://answers.Microsoft.com/en-us/IE/Forum/IE10-windows_8/Windows-8-goes-to-Bing-by-itself-all-the-time/386e9a25-8149-4EE6-84b4-65332022c2a7

    So I solved it myself. Laughing out loud.

Maybe you are looking for

  • How to close the side panel right?

    In Skype version 6.22.0.107 - installed today ' today - I can't close the right side panel. It remains a fixed size next to the vertical contacts list I'm used to. He simply eats screen real estate and it is white (white).

  • The system restore on Satellite C660

    I'm trying to restore my laptop (Satellite C660) using the restore disc, that I created when I got the computer. I put the disc and chose to start from the DVD, and it seemed to start working now, I have a black screen with a mouse pointer. How long

  • H8 Pavilion - 1280t: HP Pavilion HPE network connection not MPS 1000

    Hello My wired network connection is only 100 Mbps instead of 1000 Mbps. I have an end switch 24 ports. Other systems are shoeing 1000 Mbps connections. All HP updates are up to date. Any ideas would be greatly appreciated. Thank you Darrell

  • WRT610N (hard drive problem)

    I want to install an IOMEGA HD to my new WRT610N. When I use the LELA Setup it asks to connect the device via an Ethernet cable. Therefore, it does not recognize the IOMEGA. I'm trying to conect via a USB cable. Can someone tell me if this is possibl

  • Advantages/disadvantages of removing politics blackBerry smartphones

    Feature: 8100Carrier: T-MobileOperating system device: 4.5.0.69Desktop Manager: 4.6PC:XPNO BIS SERVICEOptional services: unlimited textUnlimited access to email Deletion of my phone IT policy will allow me to use WLM, AIM, ICQ and Yahoo messenger ser