Script for making an object the artboard size.

I am looking for some help on trying to make an object the exact size of the artboard.  This is something I do on a daily basis for several different reasons and it would be very helpful if this can happen automatically for whatever size the artboard may be.  As I understand it the only way is with a script but I have no experience with making illustrator scripts, im definately no programmer.  I have set up quickkeys in the past to copy from the artboard inputs when you are on the artboard tool but these round to the nearest .01 and this is not accurate enough for what I am working with.  Also if I do this with multiple pages open illustrator is very slow to respond to the artboard tool.  If anyone has any idea where to start or has seen other such scripts I would greatly appreciate it.  Thank you.
Below is a script that I saw on here that I believe may contain what I need but now knowing programming I have no idea where to start on editing.  All I need is the part where an object is placed on the artboard that is the exact same size as the artboard.  If anyone can advise on editing I would greatly apprecaite it.
#target illustrator
function main() {
     if (app.documents.length == 0) {
          alert('Open a document before running this script');
          return; // Stop script here no doc open…
     } else {
          var docRef = app.activeDocument;
          with (docRef) {
               if (selection.length == 0) {
                    alert('No items are selected…');
                    return; // Stop script here with no selection…
               if (selection.length > 1) {
                    alert('Too many items are selected…');
                    return; // Stop script here with selection Array…
               } else {                   
                    var selVB = selection[0].visibleBounds;
                    var rectTop = selVB[1] + 36;
                    var rectLeft = selVB[0] - 36;
                    var rectWidth = (selVB[2] - selVB[0]) + 72;
                    var rectHeight = (selVB[1] - selVB[3]) + 72;              
                    selection[0].parent.name = 'CC';
                    selection[0].filled = false;
                    selection[0].stroked = true;
                    var ccColor = cmykColor(0, 100, 0, 0);              
                    var ccCol = spots.add()
                    ccCol.name = 'CC';
                    ccCol.color = ccColor;
                    ccCol.tint = 100;
                    ccCol.colorType = ColorModel.SPOT;
                    var cc = new SpotColor();
                    cc.spot = ccCol;                   
                    selection[0].strokeColor = cc;
                    selection[0].strokeWidth = 1;                   
                    var tcLayer = layers.add();
                    tcLayer.name = 'TC';
                    var padBox = pathItems.rectangle(rectTop, rectLeft, rectWidth, rectHeight, false);
                    padBox.stroked = false;
                    padBox.filled = true;
                    var tcColor = cmykColor(0, 100, 90, 0);         
                    var tcCol = spots.add()
                    tcCol.name = 'TC';
                    tcCol.color = tcColor;
                    tcCol.tint = 100;
                    tcCol.colorType = ColorModel.SPOT;
                    var tc = new SpotColor();
                    tc.spot = tcCol;
                    padBox.fillColor = tc;    
                    padBox.move(docRef, ElementPlacement.PLACEATEND);
                    artboards[0].artboardRect = (padBox.visibleBounds);
                    redraw();
                    rectWidth = (rectWidth-72)/72;
                    rectWidth = roundToDP(rectWidth,1);
                    rectHeight = (rectHeight-72)/72;
                    rectHeight = roundToDP(rectHeight,1);
                    var textString = rectWidth + ' x ' + rectHeight;
                    prompt('Copy Me', textString);
main();
function roundToDP(nbr, dP) {
     dpNbr = Math.round(nbr*Math.pow(10,dP))/Math.pow(10,dP);
     return dpNbr;
function cmykColor(c, m, y, k) {
     var newCMYK = new CMYKColor();
     newCMYK.cyan = c;
     newCMYK.magenta = m;
     newCMYK.yellow = y;
     newCMYK.black = k;
     return newCMYK;

Thanks to CarlosCanto for the original script, it was very a very helpful starting point to optimize one of our workflows. We customized it a bit to maintain the aspect ratio (just takes the greater of the width / height and scales proportionally to the artboard size), and also center up the object in the middle of the artboard once scaling is complete. I hope it is helpful to someone:
#target Illustrator
//  script.name = fitObjectToArtboardBounds.jsx;
//  script.description = resizes selected object to fit exactly to Active Artboard Bounds;
//  script.required = select ONE object before running; CS4 & CS5 Only.
//  script.parent = carlos canto // 01/25/12;
//  script.elegant = false;
var idoc = app.activeDocument;
selec = idoc.selection;
if (selec.length==1)
        // get document bounds
        var docw = idoc.width;
        var doch = idoc.height;
        var activeAB = idoc.artboards[idoc.artboards.getActiveArtboardIndex()]; // get active AB
        docLeft = activeAB.artboardRect[0];
        docTop = activeAB.artboardRect[1];
        // get selection bounds
        var sel = idoc.selection[0];
        var selVB = sel.visibleBounds;
        var selVw = selVB[2]-selVB[0];
        var selVh = selVB[1]-selVB[3];
        var selGB = sel.geometricBounds;
        var selGw = selGB[2]-selGB[0];
        var selGh = selGB[1]-selGB[3];
        // get the difference between Visible & Geometric Bounds
        var deltaX = selVw-selGw;
        var deltaY = selVh-selGh;
        if (sel.width > sel.height) {
            var newWidth = docw-deltaX;
            var ratio = sel.width / newWidth;
            sel.width = newWidth; // width is Geometric width, so we need to make it smaller...to accomodate the visible portion.
            sel.height = sel.height * ratio;
        } else {
            var newHeight = doch-deltaY;
            var ratio = sel.height / newHeight;
            sel.height = newHeight;
            sel.width = sel.width / ratio;
        sel.top = (doch / 2) - (sel.height / 2);
        sel.left = (docw / 2) - (sel.width / 2);
    else
            alert("select ONE object before running");

Similar Messages

  • Script to align selected objects to artboard

    Hello, I was wondering if anyone had a simple solution to aligning selected items to the artboard. I was going to create an action but then realized it would be more convenient for me to include it in my script file....I have a script to align objects with each other but they dont align to the artboard. Any suggestions?

    Hello volocitygraphics,
    here is a quick&dirty solution.
    Note that the result may be different, if clipping masks are exists in the document.
    Please test it at first on copies of your documents. Use it on your own risk.
    // ArtboardCenterAroundSelectedPaths.jsx
    // works with CS5
    // http://forums.adobe.com/thread/1336506?tstart=0
    // (title: script to align selected objects to artboard)
    // quick & dirty, all selected items will be centered at the active artboard 
    // (include clipping paths  !visible result can be different)
    // regards pixxxelschubser  19.Nov. 2013
    var aDoc = app.activeDocument;
    var Sel = aDoc.selection;
    if (Sel.length >0 ) {
        var abIdx = aDoc.artboards.getActiveArtboardIndex();
        var actAbBds = aDoc.artboards[abIdx].artboardRect;
        var vBounds = Sel[0].visibleBounds;
        vBounds_Li = vBounds[0];
        vBounds_Ob = vBounds[1];
        vBounds_Re = vBounds[2];
        vBounds_Un = vBounds[3];
    if (Sel.length >1 ) {   
        for (i=1; i<Sel.length ; i++) {
            vBdsI = Sel[i].visibleBounds;
            if( vBounds_Li > vBdsI[0] ) {vBounds_Li = vBdsI[0]};
            if( vBounds_Ob < vBdsI[1] ) {vBounds_Ob = vBdsI[1]};
            if( vBounds_Re < vBdsI[2] ) {vBounds_Re = vBdsI[2]};
            if( vBounds_Un > vBdsI[3] ) {vBounds_Un = vBdsI[3]};
        aDoc.artboards[abIdx].artboardRect = [vBounds_Li +((vBounds_Re - vBounds_Li)/2-(actAbBds[2]-actAbBds[0])/2), vBounds_Ob -((vBounds_Ob - vBounds_Un)/2+(actAbBds[3]-actAbBds[1])/2), vBounds_Li +((vBounds_Re - vBounds_Li)/2-(actAbBds[2]-actAbBds[0])/2)+(actAbBds[2]-actAbBds[0]), vBounds_Ob -((vBounds_Ob - vBounds_Un)/2+(actAbBds[3]-actAbBds[1])/2)+(actAbBds[3]-actAbBds[1])];
        } else {
            alert ("No selection");
    I hope so, the document coordinatesystem is the same as in CS6+
    Have fun

  • Script for making random thumbnails from single image

    Hi all,
    I need something like a hundred different thumbnails from each image in a series of images, that is, hundred random sections of the same image, saved in a folder as jpg,  and i was hoping that i could find a script for this.
    What the script has to do is:
    select the size of the crop (this would also be the dimensions of the thumbnail saved)
    rotate crop selection in a random orientation and place the crop randomly on the canvas
    save the image as a jpg in a folder
    return to original image,
    repeat process x times before quitting script.
    I dont think this should be to difficult to make a script for, but unfortunately i don´t know how to code.
    Is there anybody that could help me with this?
    This would save me a lot of time!

    You can give this a try:
    // create copies with pseudo random clipped and rotated parts of image;
    // thanks to xbytor;
    // 2012, use at your own risk;
    #target photoshop
    if (app.documents.length > 0) {
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.POINTS;
    // set name for folder to save jpgs to;
    var folderName = "rotatedJpgs";
    // set number of jpgs;
    var theNumber = 100;
    // width and height;
    var theWidth = 500;
    var theHeight = 500;
    // calculate some values;
    var theDiagonal = Math.sqrt ((theWidth * theWidth) + (theHeight * theHeight));
    var diagAngle = angleFromRadians(Math.acos((theWidth) / (theDiagonal)));
    // get file name and path;
    var myDocument = app.activeDocument;
    var docName = myDocument.name;
    try {
              var basename = docName.match(/(.*)\.[^\.]+$/)[1];
              var docPath = myDocument.path;
    catch (e) {
              basename = docName;
              var docPath = "~/Desktop";
    // create folder if it does not exist yet;
    if (Folder(docPath + "/" + folderName).exists == true) {
              var docPath = docPath + "/" + folderName;
    else {
              var theFolder = Folder(docPath + "/" + folderName).create();
              var docPath = docPath + "/" + folderName;
    // document dimensions;
    var docWidth = myDocument.width;
    var docHeight = myDocument.height;
    // jpg options;
    var jpegOptions = new JPEGSaveOptions();
    jpegOptions.quality = 10;
    jpegOptions.embedColorProfile = true;
    jpegOptions.matte = MatteType.NONE;
    // duplicate image;
    var theCopy = myDocument.duplicate (theCopy, true);
    var origResolution = theCopy.resolution;
    theCopy.resizeImage(undefined, undefined, 72, ResampleMethod.NONE);
    var docHalfWidth = theCopy.width / 2;
    var docHalfHeight = theCopy.height / 2;
    var theLayer = smartify2010(theCopy.layers[0]);
    theCopy.resizeCanvas (theWidth, theHeight, AnchorPosition.MIDDLECENTER);
    var theHistoryState = theCopy.activeHistoryState;
    // do the variations;
    for (var m = 0; m < theNumber; m++) {
    var theAngle = Math.random() * 360;
    theLayer.rotate (theAngle, AnchorPosition.MIDDLECENTER);
    //theCopy.resizeCanvas (theWidth, theHeight, AnchorPosition.MIDDLECENTER);
    // get tolerance offset;
    var theHor1 = Math.abs(Math.cos(radiansOf(theAngle + diagAngle)) * theDiagonal / 2);
    var theVer1 = Math.abs(Math.sin(radiansOf(theAngle + diagAngle)) * theDiagonal/ 2);
    var theHor2 = Math.abs(Math.cos(radiansOf(theAngle - diagAngle)) * theDiagonal / 2);
    var theVer2 = Math.abs(Math.sin(radiansOf(theAngle - diagAngle)) * theDiagonal / -2);
    // calculate max offset for unrotated overall rectangle;
    var thisHalfWidth = docHalfWidth - Math.max(theHor1, theHor2);
    var thisHalfHeight = docHalfHeight - Math.max(theVer1, theVer2);
    // calculate random offset for unrotated overall rectangle;
    var randomX = thisHalfWidth * (Math.random() - 0.5) * 2;
    var randomY = thisHalfHeight * (Math.random() - 0.5) * 2;
    var aDiag = Math.sqrt (randomX * randomX + randomY * randomY);
    var anAngle = angleFromRadians(Math.asin((randomY) / (aDiag))) + theAngle;
    anAngle = anAngle + Math.floor(Math.random() * 2) * 180;
    // calculate  offset for rotated overall rectangle;
    var offsetX = Math.cos(radiansOf(anAngle)) * aDiag;
    var offsetY = Math.sin(radiansOf(anAngle)) * aDiag;
    //alert (theAngle+"\n\n"+offsetX +"\n"+ offsetY+"\n\n"+ thisHalfWidth+"\n"+thisHalfHeight);
    theLayer.translate(offsetX, offsetY);
    theCopy.resizeImage(undefined, undefined, origResolution, ResampleMethod.NONE);
    theCopy.saveAs((new File(docPath+"/"+basename+"_"+bufferNumberWithZeros(m+1, 3)+".jpg")),jpegOptions,true);
    theCopy.activeHistoryState = theHistoryState;
    // clean up;
    theCopy.close(SaveOptions.DONOTSAVECHANGES);
    app.preferences.rulerUnits = originalRulerUnits;
    ////// radians //////
    function radiansOf (theAngle) {
              return theAngle * Math.PI / 180
    ////// radians //////
    function angleFromRadians (theRad) {
              return theRad / Math.PI * 180
    ////// buffer number with zeros //////
    function bufferNumberWithZeros (number, places) {
              var theNumberString = String(number);
              for (var o = 0; o < (places - String(number).length); o++) {
                        theNumberString = String("0" + theNumberString)
              return theNumberString
    ////// function to smartify if not //////
    function smartify2010 (theLayer) {
    // make layers smart objects if they are not already;
              app.activeDocument.activeLayer = theLayer;
    // process pixel-layers and groups;
          if (theLayer.kind == "LayerKind.GRADIENTFILL" || theLayer.kind == "LayerKind.LAYER3D" || theLayer.kind == "LayerKind.NORMAL" ||
          theLayer.kind == "LayerKind.PATTERNFILL" || theLayer.kind == "LayerKind.SOLIDFILL" ||
          theLayer.kind == "LayerKind.TEXT" || theLayer.kind == "LayerKind.VIDEO" || theLayer.typename == "LayerSet") {
                        var id557 = charIDToTypeID( "slct" );
                        var desc108 = new ActionDescriptor();
                        var id558 = charIDToTypeID( "null" );
                        var ref77 = new ActionReference();
                        var id559 = charIDToTypeID( "Mn  " );
                        var id560 = charIDToTypeID( "MnIt" );
                        var id561 = stringIDToTypeID( "newPlacedLayer" );
                        ref77.putEnumerated( id559, id560, id561 );
                        desc108.putReference( id558, ref77 );
                        executeAction( id557, desc108, DialogModes.NO )
                        return app.activeDocument.activeLayer
              if (theLayer.kind == LayerKind.SMARTOBJECT || theLayer.kind == "LayerKind.VIDEO") {return theLayer};
    ////// get an angle, 3:00 being 0˚, 6:00 90˚, etc. //////
    function getAngle (pointOne, pointTwo) {
    // calculate the triangle sides;
              var width = pointTwo[0] - pointOne[0];
              var height = pointTwo[1] - pointOne[1];
              var sideC = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
    // calculate the angles;
              if (width+width > width) {theAngle = Math.asin(height / sideC) * 360 / 2 / Math.PI}
              else {theAngle = 180 - (Math.asin(height / sideC) * 360 / 2 / Math.PI)};
              if (theAngle < 0) {theAngle = (360 + theAngle)};
              return theAngle

  • Shell Script  for Startup and Shutdown the database

    Hi,
    i want Shell Script for Startup and Shutdown the database in Solaries.
    could any one can hep me where i can get this script. or send to me to [email protected]
    Thanks & Regards,
    Gangi reddy

    SHUTDOWN
    SHUTDOWN ABORT]
    Shuts down a currently running Oracle instance, optionally closing and dismounting a database.
    Terms
    Refer to the following list for a description of each term or clause:
    ABORT
    Proceeds with the fastest possible shutdown of the database without waiting for calls to complete or users to disconnect.
    Uncommitted transactions are not rolled back. Client SQL statements currently being processed are terminated. All users currently connected to the database are implicitly disconnected and the next database startup will require instance recovery.
    You must use this option if a background process terminates abnormally.
    IMMEDIATE
    Does not wait for current calls to complete or users to disconnect from the database.
    Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
    NORMAL
    NORMAL is the default option which waits for users to disconnect from the database.
    Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
    TRANSACTIONAL [LOCAL]
    Performs a planned shutdown of an instance while allowing active transactions to complete first. It prevents clients from losing work without requiring all users to log off.
    No client can start a new transaction on this instance. Attempting to start a new transaction results in disconnection. After completion of all transactions, any client still connected to the instance is disconnected. Now the instance shuts down just as it would if a SHUTDOWN IMMEDIATE statement was submitted. The next startup of the database will not require any instance recovery procedures.
    The LOCAL mode specifies a transactional shutdown on the local instance only, so that it only waits on local transactions to complete, not all transactions. This is useful, for example, for scheduled outage maintenance.
    Usage
    SHUTDOWN with no arguments is equivalent to SHUTDOWN NORMAL.
    You must be connected to a database as SYSOPER, or SYSDBA. You cannot connect via a multi-threaded server. For more information about connecting to a database, see the CONNECT command earlier in this chapter.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013607
    Joel Pérez

  • Run preupgrade script for AppleMobileDeviceSupport. Contact the software manufacturer for assistance.

    everytime i try to update itunes this is what it says
    run preupgrade script for AppleMobileDeviceSupport. Contact the software manufacturer for assistance.

    C,
    I ran into the same issue. Make sure your apple device in disconnected from the computer. It interrupts the itunes download. Disconnect and make sure itunes is closed, then try installing again. Remember that even though you close of itunes, it is often still running in the background. To make sure it's closed, click and hold the mouse on the itunes icon and select quit from the drop down menu. Then try installing the updated itunes.
    Hope that helps.
    SoEreal

  • I keep getting this message when wanting to download latest itunes software update :The following install step failed: run preupgrade script for AppleMobileDeviceSupport. Contact the software manufacturer for assistance. what can i do to download?

    The following install step failed: run preupgrade script for AppleMobileDeviceSupport. Contact the software manufacturer for assistance. what can i do to download software when the above message keeps popping up...not allowing me to download

    I had the same problem this weekend.  The iphone 4s needed Itunes10.5 to sync to her Asus Windows 7 Laptop.  When I tried to download from the Apple website I got the error that the windows installer was missings files or something like that.  I uninstalled itunes and tried again but that didn't work.  Then I redownloaded itunes 10.3 just to have a working version in case I gave up.  Then I found site that suggested I update Windows by going through the start menu and while doing that I found an update Apple itunes file. 
    Goto Start and type Widows Update in the seach window.  Click on check for updates (I already was current with all updates but I suggest you download the updates if there are some available.
    Goto start and this time just type update in the search window.  Look for the Apple itunes update link and click on it.  It found there were updates for itunes 10.5, Quick time, Safari, and Icloud.  I checked all the updates except for Safari, since we don't use it (yet).
    The install started then seemed to stall at one spot for ~3min but then completed successfully.  I open itunes and had her synced with Outlook Contact, Email, Calender, and Notes in 5 minutes.  I did already configure Outlook by going to tools and Trust Center.
    I hope this works.

  • The following install step failed: run preupgrade script for AppleMobileDeviceSupport. Contact the software manufacturer for assistance.

    Just upgraded software. When system prompts to update itunes and in the middle of the system's attempt to complete the upgrade, the message, "The following install step failed: run preupgrade script for AppleMobileDeviceSupport. Contact the software manufacturer for assistance" appears.
    I don't understand what "preupgrade" needs to be done.
    Anyone else experience this?
    Suggestions?

    -= Pre Upgrade Script Error with iTunes =-
    Do a general web search and you will discover there are many answers, none definitive.
    iTunes: How to remove and reinstall the Apple Mobile Device Service on Mac OS X 10.6.8 or Earlier - http://support.apple.com/kb/ht1747
    scarier:
    https://discussions.apple.com/message/10464515#10464515

  • Feather radius for selection depending on the image size

    Greetings everyone,
    I have a question about setting the feather radius for a selection depending on the image size. I'd like make the edge in the resultant layer mask have roughly the 'same' feather appearance for varying image sizes.
    For files below 2000 pixels I would set  a feather radius of 0.2
    For files above 2000 pixels I would set  a feather radius of 0.3
    However, I started working with 4000-10000 pixel images and I was wondering about the radius for those images.
    Is there a more 'scientific' method I could follow? Any thoughts welcome
    Many thanks
    gr

    You would need to use Photoshop scripting to do that. Also using number of Pixels might not be what you want to use.  While number pixel is an absolute number pixels you have have no size information till there is a DPI resolution involved. At 300 DPI 300 pixels are 1" in size at 72 DPI 300 pixels are 4.16 inches in size.
    A conditional action is not possible adobe conditional action support but is possible with the downloadable script  Siva's Contitional Action

  • How to make a script for find text object?

    Hi everyone
    I want to make a script for find and select text object and then find next, find next, and so on, but without any open dialog
    Is that possible make a script for this?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "(\[\x{2022}\])|(\x{25CF})";
    app.findGrep();
    thanks
    Regard

    You already have that. A script does not 'find, select, find next' - it finds all texts as soon as you execute the 'app.findGrep' command.

  • Can anybody fix this apple script for me so all the responses work

    iv been working on a jarvis wake up script and iv continued to add on commands to if theResponce parts of the script but now most of them wont work and i get a syntax if i dont have like 8 end if's at the end of the script could somebody please overview it, fix the script and resubmit it to me in the comments. will be so grateful if somebody fixes this pleasee.!!!!
    set theHours to hours of the (current date)
    if theHours > 18 then
              say "good evening sir"
    else if theHours > 12 then
              say "good afternoon sir"
    else if theHours > 6 then
              say "good Morning sir"
    else if theHours > 0 then
              say "get out of bed sir!"
    end if
    say "It is " & getTimeInHoursAndMinutes() using "Tom"
    on getTimeInHoursAndMinutes()
              set timeStr to time string of (current date)
              set Pos to offset of ":" in timeStr
              set theHour to characters 1 thru (Pos - 1) of timeStr as string
              set timeStr to characters (Pos + 1) through end of timeStr as string
      -- Get the "minute"
              set Pos to offset of ":" in timeStr
              set theMin to characters 1 thru (Pos - 1) of timeStr as string
              set timeStr to characters (Pos + 1) through end of timeStr as string
      --Get "AM or PM"
              set Pos to offset of " " in timeStr
              set theSfx to characters (Pos + 1) through end of timeStr as string
              return (theHour & ":" & theMin & " " & theSfx) as string
    end getTimeInHoursAndMinutes
    set CityCode to 1098081
    set t_format to "C"
    set v_format to "S"
    set a_format to "Y"
    set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode
    set file_content to (do shell script "curl " & IURL)
    --looking for the line with actual condition
    set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
    set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText
    set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1
    set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
    set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
    set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b
    if t_format is equal to "C" then
              set actual_temp to (5 / 9) * (actual_temp - 32) as integer
    end if
    set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
    set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText
    set today_min_temp to word 9 of sub_2
    set today_max_temp to word 12 of sub_2
    if t_format is equal to "C" then
              set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
              set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
    end if
    set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
    set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
    set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4
    set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
    set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5
    set tomorrow_min_temp to word 9 of sub_6
    set tomorrow_max_temp to word 12 of sub_6
    if t_format is equal to "C" then
              set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
              set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
    end if
    set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
    set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
    set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8
    if a_format is equal to "Y" then
              say "The current conditions in Perth are " & actual_condition & " ,and the current temperture is " & actual_temp & " degrees"
    end if
    if v_format is equal to "L" then
              say "Today it will be : " & today_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees .
              Tomorrow we are expecting it to be: " & tomorrow_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees " using "Tom"
    else
              say "Today it will be : " & today_forecast & ", between " & today_min_temp & " , and " & today_max_temp & " degrees .
               Tomorrow we are expecting it to be: " & tomorrow_forecast & ", between " & tomorrow_min_temp & " ,and " & tomorrow_max_temp & " degrees " using "Tom"
              say "will that be all sir?"
              tell application "SpeechRecognitionServer" to set theResponse to listen for {"get my mail ", "yes", "notes", "repeat", "Music", "Sleep in"}
              if theResponse is "Sleep in" then
      delay 6
                        say "Time to get up sir,or you will be late"
                        tell application "SpeechRecognitionServer" to set theResponse2 to listen for {"Ok pat im getting up"}
                        if theResponse2 is "Ok pat im getting up" then
      set volume 35
                                  tell application "iTunes"
                                            set the sound volume to 0
      play user playlist "Wake up"
                                            repeat 10 times
                                                      if sound volume is less than 40 then
                                                                set sound volume to (sound volume + 10)
                                                                delay 2
                                                      end if
                                            end repeat
                                  end tell
                                  if theResponse is "Music" then
      set volume 20
                                            tell application "iTunes"
                                                      set the sound volume to 0
      play user playlist "Wake up"
                                                      repeat 10 times
                                                                if sound volume is less than 60 then
                                                                          set sound volume to (sound volume + 10)
                                                                          delay 2
                                                                end if
                                                      end repeat
                                            end tell
                                            if theResponse is "yes" then
                                                      delay 1
                                                      set theOptions to {"very good, sir, have a nice day"}
                                                      set theChoice to some item of theOptions
      say theChoice displaying theChoice with waiting until completion
                                            end if
                                            if theResponse is "get my mail " then
                                                      tell application "Mail" to launch
                                            end if
                                            if theResponse is "notes" then
                                                      tell application "Stickies" to launch
                                            end if
                                            if theResponse is "repeat" then
                                                      set CityCode to 1098081
                                                      set t_format to "C"
                                                      set v_format to "S"
                                                      set a_format to "Y"
                                                      set IURL to "http://weather.yahooapis.com/forecastrss?w=" & CityCode
                                                      set file_content to (do shell script "curl " & IURL)
      --looking for the line with actual condition
                                                      set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
                                                      set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText
                                                      set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1
                                                      set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
                                                      set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
                                                      set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b
                                                      if t_format is equal to "C" then
                                                                set actual_temp to (5 / 9) * (actual_temp - 32) as integer
                                                      end if
                                                      set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
                                                      set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText
                                                      set today_min_temp to word 9 of sub_2
                                                      set today_max_temp to word 12 of sub_2
                                                      if t_format is equal to "C" then
                                                                set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
                                                                set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
                                                      end if
                                                      set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
                                                      set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
                                                      set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4
                                                      set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
                                                      set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5
                                                      set tomorrow_min_temp to word 9 of sub_6
                                                      set tomorrow_max_temp to word 12 of sub_6
                                                      if t_format is equal to "C" then
                                                                set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
                                                                set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
                                                      end if
                                                      set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
                                                      set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
                                                      set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8
                                                      if a_format is equal to "Y" then
                                                                say "The current conditions in Perth are " & actual_condition & " ,and the current temperture is " & actual_temp & " degrees"
                                                      end if
                                                      if v_format is equal to "L" then
                                                                say "Today it will be : " & today_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees .
              Tomorrow we are expecting it to be: " & tomorrow_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees " using "Tom"
                                                      else
                                                                say "will that be all sir?"
                                                                tell application "SpeechRecognitionServer" to set theResponse3 to listen for {"get my mail ", "yes", "notes", "Music"}
                                                                if theResponse3 is "Music" then
                                                                          set volume 20
                                                                          tell application "iTunes"
                                                                                    set the sound volume to 0
                                                                                    play user playlist "Wake up"
                                                                                    repeat 10 times
                                                                                              if sound volume is less than 60 then
                                                                                                        set sound volume to (sound volume + 10)
                                                                                                        delay 2
                                                                                              end if
                                                                                    end repeat
                                                                          end tell
                                                                else
                                                                          if theResponse3 is "get my mail " then
                                                                                    tell application "Mail" to launch
                                                                          end if
                                                                          if theResponse3 is "yes" then
                                                                                    delay 1
                                                                                    set theOptions to {"very good, sir, have a nice day"}
                                                                                    set theChoice to some item of theOptions

    What you do in this situation, is split the file into parts. 
    Start with:
    set theHours to hours of the (current date)
    if theHours > 18 then
              say "good evening sir"
    else if theHours > 12 then
              say "good afternoon sir"
    else if theHours > 6 then
              say "good Morning sir"
    else if theHours > 0 then
              say "get out of bed sir!"
    end if
    Add in a few lines of code to this file and see what happens. 
    add the on run, this would be clearer.  It is the default on unit to run.
    on run
        set theHours to hours of the (current date)
        if theHours > 18 then
            say "good evening sir"
        else if theHours > 12 then
            say "good afternoon sir"
        else if theHours > 6 then
            say "good Morning sir"
        else if theHours > 0 then
            say "get out of bed sir!"
        end if
    end run
    Now, it is time for debugging.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set desktopPath to (path to desktop) as string
        log "desktopPath = " & desktopPath
    end run

  • Script for adding layer name to artboard as text

    I've found scripts that are sort of close but not quite this.
    I have 1 artboard and many layers (see image).
    Does anyone have a script that will take the name of the layer, ie "01_Intro" and create and then place the text "01_Intro" on to the art board in layer 01_Intro? Then it would repeat the process for all the present layers?
    Thanks in advance!

    Waterbear,
    something like this?
    // LayersnamesInUpperLeftCorner.jsx
    // https://forums.adobe.com/thread/1546630
    // write layers names in upper left corner of the active artboard
    // required: opened document, no toplevel layers locked, all layers visible
    // regards pixxxelschubser
    var aDoc = app.activeDocument;
    var theLayers = aDoc.layers;
    for (i=0; i<theLayers.length; i++) {
        var txt = theLayers[i].textFrames.add();
        txt.position = [0,0];
        txt.contents = theLayers[i].name;
    Have fun

  • Script for automated partitioning in the next official release?

    Disclaimer: don't run it with root privileges unless /dev/sda is a blank disk. You have been warned.
    # dhcpcd
    # curl sprunge.us/WATU > autopart #Uppercase required.
    # nano autopart
    # sh autopart
    http://sprunge.us/WATU
    Tested in VirtualBox.
    I remember that the AIF used 100 MB for /boot and 7.4 GB for "/". Close enough, right?
    Users can also edit the script and make their own version. What do you think?
    Last edited by DSpider (2012-08-07 08:22:26)

    DSpider wrote:
    Here's what it looks like multiplied by 1024: http://i.imgur.com/fttkB.png
    And here's what it looks like by 1000: http://i.imgur.com/oaCxF.png
    I don't know about you, but I very much dislike 7.81 GB, 1.95 GB, etc. If you're going to test it in VirtualBox, please create a virtual drive of at least 15.1 GB (100+8+2+5), or, you know, use smaller numbers. Also, using "Dynamic Size" only takes up about 60 MB or so of actual space, so you may as well create a 20 GB+ virtual drive.
    I am doing the max calculation directly on my desktop computer and using 1000 is the only result that corresponds to the label on the disk, so to speak. I'm not sure though, have to look closer at this when I get the time.

  • Is there a script to give two objects the same height ?

    The heighest object must remain. The little object has to become as high as the big one.
    I need this in a script.
    Geert.

    Cok guzel bir yazi yazmissiniz canlı tv

  • IND 3 or 4: script for making INDEX

    Hi,
    When typesetting books in Indesign cs3/4 (OSX), some of our texts contain words tagged like this: [r]word[#r].
    Those are the words which should end up in the index. It's a timeconsuming job to select these tagged words by hand, apply the 'create a new index entry' (apple-u), and move on to the next one.
    Can someone write a script that automates this nasty job for me? Search for the word between the paranthesis, apply apple-u, move on to the next one.
    I hope it won't be difficult for someone who is used scripting around in indesign.....
    greetings, frits

    Hi Frits,
    Check out this script (post5):
    Peter Kahrel, "Footnote behaviour" #5, 3 Dec 2008 7:24 am
    Kasyan

  • ORCH on R for BDA always shows the file size as 0

    I am unable to attach any file in my r console for BDA (ORCH)
    hdfs.ls()[1] "claims_med" "stocktick"
    hdfs.size("bdatest")[1] 0
    hdfs.size("claims_med")[1] 0
    dfs <- hdfs.attach("stocktick")Error in if (is.na(fmt)) { : argument is of length zero
    In addition: Warning messages:
    1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
    2: In is.na(fmt[i]) :
    is.na() applied to non-(list or vector) of type 'NULL'
    >

    Thanks for the reply Mark,
    I did as you suggested, loaded the file from local, using hdfs.upload,
    also I am getting the below exception now,
    sdfs <- hdfs.attach("stocktick")Error in if (.sh.error() != 0) { : missing value where TRUE/FALSE needed
    In addition: Warning messages:
    1: In .sh(cmd = cmd, nlines = nlines, noerr = noerr) :
    NAs introduced by coercion
    2: In .sh(cmd = cmd, nlines = nlines, noerr = noerr) :
    NAs introduced by coercion
    >

Maybe you are looking for