Resize then check collide and repeat untill max

I've got a trapezoid that is the guide box and artwork that needs to always be maxed size to fit it.  I've wrote a script that will place the artwork bottom center then move it up 3points so that it isn't touching.  I need the script to loop through and resize by 101% then redo the center function and check collide again.  I'm not even sure if there is a .collide or how to go about that but I went ahead and wrote the rest of the script.  The part that reads "arttouchguide.collide" on line 07 is the part that I'm having problems with and it is just a place holder as I know that it doesn't work right now.  Below the code is a .jpg of what I'm working with.
#target illustrator
  var selecteditem = app.activeDocument.groupItems[0];
  for ( arttouchguide.collide = false)
   selecteditem.resize(101,101);
   centerArt()
function centerArt()
       var thisdoc = app.activeDocument; 
        var selecteditem = app.activeDocument.groupItems[0];
        selecteditem.selected = true;
        var hasDocCoords = app.coordinateSystem == CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
        var p = thisdoc.pageItems; 
        for (var i = 0, l = p.length; i < l; i++) { 
            var pID = p[i]; 
            if (pID.guides == true) { 
                var guideBox = pID 
        var wNum = guideBox.width; 
        var hNum = guideBox.height;
        var swNum = selecteditem.width;
        var shNum = selecteditem.height;
        var sxOffset = (swNum/2);
        var syOffset = (shNum);
        var xOffset = (wNum/2);
        var yOffset = (hNum-3);
        var xNum = guideBox.position[0]+xOffset; 
        var yNum = guideBox.position[1]-yOffset;
        var guideXCenter = xNum-sxOffset;
        var guideYCenter = yNum+(syOffset);
        var sxNum = selecteditem.position[0]+sxOffset;
        var syNum = selecteditem.position[1]-syOffset;
        //to test your script for position un annotate the two alerts below
              // alert("GuideBox Data:\nWidth: "+wNum+"\nHeight: "+hNum+"\nX Position: "+xNum+"\nY Position: "+yNum);
              // alert ("Selected object Data:\nWidth: "+swNum+"\nHeight: "+shNum+"\nX Position: "+sxNum+"\nY Position: "+syNum);
        //changes the position of the selected artwork to the center of the guide box.
        selecteditem.position = [guideXCenter, guideYCenter]   
    }//end centerart
The red line is the guide box, the lime part is the artwork.  It will increase the size of the art, recenter it, move it up 3 points and check for overlap/collide and repeat till it is touching.  This is the only way that I can think of to max out the artwork inside a trapezoid.

I had been working on this since I posted it and between the two posts below I had come up with the following.  Funny thing is one of them is yours Carlos.
How to select only objects within a selection marquee?
Re: How to check if a path fits inside of another path?
There was one more but I failed to bookmark it.  It took the artwork that was selected, rasterized it, live traced it so that you had one path going along the outside of the groupitem.
Here is the code that I have so far;
#target illustrator
  var selecteditem = app.activeDocument.groupItems[0];
  var artworkmax = false
  //to count the number of tries
  var trycount = 0;
if (app.activeDocument.selection.length > 0)
    findguide ()
  if (guidetoggle == false)
      alert ("There is not a guide box to size to")
      }//end if
  for (a=0;artworkmax == false || a>1000; a++)
   selecteditem.resize(102,102);
   centerArt()
   merge()
   findguide()
   trycount++
          if (artworkmax == true)
            alert ("Script tried " + trycount + " number of times")
}/*end if anything open check*/ else
    alert ("Nothing selected")
function centerArt()
       var thisdoc = app.activeDocument; 
        var selecteditem = app.activeDocument.groupItems[0];
        selecteditem.selected = true;
        var hasDocCoords = app.coordinateSystem == CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
        var p = thisdoc.pageItems; 
        for (var i = 0, l = p.length; i < l; i++) { 
            var pID = p[i]; 
            if (pID.guides == true) { 
                var guideBox = pID 
        var wNum = guideBox.width; 
        var hNum = guideBox.height;
        var swNum = selecteditem.width;
        var shNum = selecteditem.height;
        var sxOffset = (swNum/2);
        var syOffset = (shNum);
        var xOffset = (wNum/2);
        var yOffset = (hNum-3);
        var xNum = guideBox.position[0]+xOffset; 
        var yNum = guideBox.position[1]-yOffset;
        var guideXCenter = xNum-sxOffset;
        var guideYCenter = yNum+(syOffset);
        var sxNum = selecteditem.position[0]+sxOffset;
        var syNum = selecteditem.position[1]-syOffset;
        //to test your script for position un annotate the two alerts below
              // alert("GuideBox Data:\nWidth: "+wNum+"\nHeight: "+hNum+"\nX Position: "+xNum+"\nY Position: "+yNum);
              // alert ("Selected object Data:\nWidth: "+swNum+"\nHeight: "+shNum+"\nX Position: "+sxNum+"\nY Position: "+syNum);
        //changes the position of the selected artwork to the center of the guide box.
        selecteditem.position = [guideXCenter, guideYCenter]   
    }//end centerart
function findguide()
var thisdoc = app.activeDocument; 
var p = thisdoc.pageItems;
var guidetoggle = false
        for (var i = 0, l = p.length; i < l; i++)
            var pID = p[i]; 
            if (pID.guides == true)
                var guideBox = pID
                var guidetoggle = true;
                }/*end if*/
            }//end for
        if (guidetoggle == true)
            //alert ("Found Guides")
            }/*end if*/ else
           // alert ("No Guides")
            artworkmax = true
            selecteditem.resize(99,99);
            }//end else
}//end function
function merge()
//function to merge both art and guide box
//when they are merged if the art overlaps with anything turned to guides
//it makes the guides disappear. So after you do this, run FundGuide if guidetoggle = False
//then the art and the guide overlapped
if (guidetoggle = true)
    var thisdoc = app.activeDocument;
    var p = thisdoc.pageItems;
            for (var i = 0, l = p.length; i < l; i++)
            var pID = p[i]; 
            if (pID.guides == true)
                var guideBox = pID               
                }/*end if*/
            }//end for
  var selecteditem = app.activeDocument.groupItems[0];
  //var artguidegroup = selecteditem && guidebox
  //var artguidegroup.selected = true;
  app.executeMenuCommand ('Live Pathfinder Merge');
  }//end if guides are present then run merge
  }//end merge function
function wait10() 
  while(a<100)  
    a++;
    if (a>99) break; // guard against infinite loop 
I had to up it from the 101% increase as it was bogging down the section if there were a lot of points but when I did it wasn't as accurate.  I'm going to set it up to enlarge by 5 percent - Collide then resize by "95.24%" then do it again at 101%
I had started on your path but my brain died when I got to around your number 7 so I started fishing for codes.
Thank you for all your help guys.

Similar Messages

  • My iphone 3g stays on the apple logo for about 4 minutes then flashes white and goes back to the apple screen, it repeats untill battery is flat,  every now and then im lucky enough to get it to turn on but not very often and then it freezes and repeats??

    hello my name is kirstie, i updated to firmware 4.2.1 .....my iphone 3g stays on the apple logo for about 4 minutes then flashes white and goes back to the apple screen, it repeats untill battery is flat,  every now and then im lucky enough to get it to turn on but not very often and then it freezes and repeats the same problem?? (if i turn the phone off my pressing the two buttons it wont keep rebooting, its only when i leave it after turning it on)
    I have reset the phone, full firmware restore, even downgraded back from firmware 4.2.1 to .3.1.3 official by using dfu mode and still doesnt fix.
    (i correctly got out of dfu mode after the downgrade)
    i can enter dfu mode and recovery, and update through itunes with no problem, but it doesnt fix the problem,
    i have searched and found no answer to this problem, every option availible to try that i know of i have tried and failed. i dont care about preserving my content i just want a fix. i have a good understanding how to operate software on a computer and shouldnt be too confused by any advice given, so plz even if the answer is very complex i wish to try anything, please help me to get my iphone working.

    Anyone have any suggestions? or is everyone else just as clueless as me !

  • Blackberry 8220 Flip phone gives red light, then shows clock and repeats...... forever....!

    Hi I have a blackberry pearl 8220 flip that's bricked. It goes from a long red light to the clock loading screen and continues until by battery is dead.
    I have tried reloading the current OS available (v4.6.0.174) through the latest blackberry desktop manager several times, and I did select the options to completely wipe all data on the pearl. I got the desktop manager to detect the phone by taking out the battery at first, and then putting it in. The reload worked properly, everything got wiped off and the os was reinstalled. It worked for a couple of hours, but the problem pops up again. I've even tried reloading an older os (4.5) but it doesn't work either.
    Please help...

    Hmmm...OK, then you might need to completely wipe it out first and then reload the OS...see this:
    http://forums.crackberry.com/f3/how-wipe-jl_cmder-53502/
    If that fails, then you are probably ready for warranty support -- from your carrier.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • IPod Touch 2nd Gen (8gb) Loads to Apple symbol, then turns off, and repeats.

    Okay so I went into my settings to do a reset on the iPod Touch. I did the reset and now all the iPod does is load the the black screen with the Apple symbol, stay on for a few minutes, turn off, and repeat.
    When I connect the iPod to ANY computer with iTunes, it doesn't even show the iPod as connected. I honestly do not know what to do.
    Does anyone have a solution on how to fix this?

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       
    Did you by chance not have the iPod connected to a charging source during the erase? It can take hours ao a 1G and 2G iPod and fully drain the battery before it is complete.

  • HT201412 Hello I made a update on my ipod to the ios 6 and its just been showing the apple logo then goig off and repeating that any ideas or help please?

    I made a update to the ios 6 and now its just showing the apple logo and going off to black and repeating tat any help please?

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
      Apple Retail Store - Genius Bar              

  • I recently bought the first generation ipod touch, but it doesn't work. I've tried restarting over and over, i've tried switching cables too. The apple logo stays on the screen and freezes, it then shuts down and repeats. My laptop doesnt recognize it.

    Please help
    I bought it through a mutual friend.

    - Connect the iPod to your computer and try to make a backup
    iOS: How to back up and restore your content
    - Next reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    and try making a backup again. If you can't then there is no way of getting the info off the iPod unless data recovery company can do it. Not cheap.
    - If photos are in an existing iPod backup (iTune>Preferences>Devices  for iTunes backup or an iCloud backu) then restore from that backup. See the restore topic of:
    iOS: How to back up
    - If you used PhotoStream then try getting them from your PhotoStream. See that topic of:
    iOS: Importing personal photos and videos from iOS devices to your computer

  • My notebook turns on to the orange screen with the c ( for compac) then turns black and repeats. y?

    please help. i have norton virus protector

    I have a similar problem. Not sure you're on here (since the post is really old) but did you manage to work it out? How?
    My thread:
    https://discussions.apple.com/message/19007548#19007548
    My Imac froze earlier today as I was dragging an image from safari into indesig and when it froze the weirdest pattern overlaid the screen. It looked just like the opacity pattern from photoshop with grey and white squares. I turned the computer off using the power button and unplugged everything.
    Now when I try to start it these weird lines appear on my start up screen (see link)...
    http://meijerladdaruppgrejer.wordpress.com/2012/07/24/oops/
    as you can see the apple and the wheel appears as normal...
    ... then it moves to a normal looking white screen (perhaps a bit greener than usual) and around 30 seconds later freezes at the blue screen.
    I've tried the cmd + alt + p + r several times but it won't help.
    If i press alt during start up I can see and choose my hard drive but just end up at the blue screen again.
    Can I try starting it up in safe mode or something?

  • Iphone 4s freezing at start up then shuts off and keeps restarting then repeating that process over and over. I have tried to reset the phone two different ways and still this problem occurs after I update it or turn off the phone.

    yes the title says most of what is going on.
    I recently reset my phone, losing all contacts and pictures. It was working fine, then after I updated it, it will not turn on completely.
    It starts up with the apple logo
    -goes to the ios 6 (please slide to open) screen
    -then shuts off
    -and repeats the process unless I shut the phone off manually
    I have tried to hold the lock and the home button down to manually reset the phone
    I have also tried reseting the phone completely previously, and I still have this problem.
    Any ideas?
    Thank you!!

    I really don't have an answer for that one. I guess that while trying to get things working correctly, I would use the most basic monitor I had which in your case would be the Eizon using the Thunderbolt port and adaptor.
    When you boot into Safe Mode the startup is quite slow, but you should get the Apple logo and then the spinning gear below it (release the SHIFT key when it appears.) Then after a little more time you should see a gray progress bar appear below the spinning gear. When that disappears the computer will startup to a login screen.

  • Multiple lables Automatic Multiply and Repeat to 12 times in a A3

    Hello there all, I've been running all over the net trying to find a solution to make my life a little easier without success so I was hoping that maybe somebody would have an idea of a better way to do this.
    I make personalized Tea Labels for a client, 6 different labels per order.
    I make these as separate pages in InDesign size 9 cm x 12 cm
    Then I need to put each one into an A3 format repeated 12 times with cut lines and a unified background color and save and renamed as the label.
    This is how I do it so far:
    -          Create the pages in InDesign
    -          Export to Acrobat
    -          Acrobat > Extract pages as separate files
    -          InDesign > Open an A3 Template with the PDF repeated as an image.
    -          Replace the Image
    -          Save rename and export to PDF
    Any help or ideas are really appreciated
    Thanks
    Tiola

    But you don't NEED to export at all.
    Make up your 6-page file of one-up labels sized correctly.
    Create a new large sheet file, also 6 pages, and add the trim marks and background color (if it's the same for all labels) to the master page, then add ONE frame in the upper left position on the master to hold one label image. Move to page 1.
    File > Place.... and navigate to your one-up file. Show import options and pick all pages when you click OK. Hover the loaded cursor in the master frame area and click once to load the first label, then move to each successive page and repeat until you have one label on each page.
    On each page, select the frame with the placed label and use Step and Repeat to make your grid.
    Done.

  • Are there any plans to move the "Math Check" to AFTER the O.K. BUTTON is pushed on STEP AND REPEAT?

    One of my pet peeves is that I have to clear all the fields in the STEP AND REPEAT dialouge box before I can begin entering information.  I have been patiently waiting for this bug to be fixed.  I am beginning to wonder if Adobe is even aware of the bug?  It drives me nuts to no end!!!  I am sure it is responsible for several points in my blood pressure reading on given days.  I'll have an object selected that I need to step 7 times and I'll bring up the Step and Repeat dialouge box.  I'll enter 7 in the COUNT field.  InDesign will in some cases immediately flag the operation as not possible because there are numbers in the other two fields that I haven't had a chance to edit yet that will cause the step and repeat operation to go off the pasteboard.  It makes me MAD because it changes my 7 back to a 1 and I have to go and put in the correct values for the VERTICAL and HORIZONTAL offset fields and then I have to go back up to the COUNT field and re-enter my 7.  All of this and I haven't even hit the O.K. button yet!!!  Can someone at Adobe pleeeeeeaaaaaase inform the programmers of this glitch and have them move the MATH CHECK to AFTER THE O.K. BUTTON is clicked!  I wouldn't mind the message if the figures I entered were incorrect and I had hit the O.K. button.  But it drives me absolutely insane when it starts trying to correct me before I've even finished entering my values!
    Am I the only one?
    I would love to hear from anyone else out there that gets frustrated from this.  If for no other reason then to let me know I haven't completely lost my sanity yet.
    Thanks.
    Randy

    O.K. Peter.  I did go and file a report.  I couldn't bring myself though to call it a feature request because I clearly believe it is a bug.  A co-worker of mine and I had a long discussion about it.  He argued your side of things suggesting that the program was working as the programmers intended for it to be and because of that I couldn't call it a bug.  But, I contend that the program IS NOT working as the programmers intended for it to be because if you look at the OBJECT > TRANSFORM > MOVE item in InDesign it also brings up a dialogue box.  This dialogue box also has a PREVIEW check box on it.  If the PREVIEW check box is checked then it immediately evaluates the numbers as you enter them into the various fields.  And if you enter an invalid number it will immediately present the error message.  However, if the PREVIEW check box is left unchecked then it waits until you press the O.K. Button before evaluating the numbers and executing the move.  The STEP AND REPEAT dialogue box should behave the same way but it doesn't.  It behaves as if the PREVIEW check box is checked whether it is or not.  So that is a BUG in my humble opinion.
    Thanks for your help in pointing me to the correct form.  I'm usually so busy working that I never have time to look that kind of stuff up.
    Randy

  • ''Well When i plug in my ipod touch the battery life is low..i let it sit a wyhle.And it starts up to the apple logo and it stay there some time then it restartsback over to the very low battery and repeat(Over&Over)?

    ''Well When i plug in my ipod touch the battery life is low..i let it sit a wyhle.And it starts up to the apple logo and it stay there some time then it restartsback over to the very low battery and repeat(Over&Over)

    Can you reset the device by holding the sleep and home button until the Apple logo comes back again?
    If this does not work, try to connect in recovery mode, explained here: iOS: Unable to restore

  • Ipod keeps turning itself on and off repeatedly until battery goes dead

    please help.....my ipod just keeps turning itself on and off repeatedly until the battery goes dead. The only thing that will show up on the screen is the apple logo and then it will power cycle over and over and over! I have tried reseting it but I am limited to what I can do because the computer will not recognize the ipod when i connest it to my computer.

    Take it to your local Apple Store

  • When I charge my ipod, the apple symbol comes up as if it was turning on, then it goes black and repeats the process. Sometimes it gets to where I have to put in my 4 digit code to unlock it then goes black, any suggestions on why it does this?

    When I charge my ipod, the apple symbol comes up as if it was turning on, then it goes black and repeats the process. Sometimes it gets to where I have to put in my 4 digit code to unlock it then goes black, any suggestions on why it does this?

    Does it work OK otherwise?
    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Try another cable and USB port and/or charging source
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.             
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar                                      

  • TS3694 My phone keeps freezing, the apple sign appears on the screen and then it freezes again and repeats itself.. has anyone had this before? it's also not letting me restore it from iTunes, it keeps coming up with error (9) or error (14).. help?

    My phone keeps freezing, the apple sign appears on the screen and then it freezes again and repeats itself.. has anyone had this before? if so, what is it? & it's also not letting me restore it from iTunes, it keeps coming up with error (9) or error (14).. help?

    Hi there Holly N,
    You may find the troubleshooting steps in the article below helpful.
    Resolve specific iTunes update and restore errors
    http://support.apple.com/kb/ts3694
    Configure your security software
    Related errors: 2, 4, 6, 9, 1000, 1611, 9006, 9807, or 9844. Sometimes as a result of this issue, a device might stop responding during the restore process.
    Check your security software and settings, which can block ports and prevent connection to Apple servers during update and restore.
    -Griff W. 

  • Why can't I get alert tones when I send or receive email.  I checked Sounds and volumes are at max.

    Why can't I get alert tones when I send or receive email.  I checked Sounds and volumes are at max.

    Have you got notifications muted ? Only notifications (including games) get muted, so the iPod and Videos apps, and headphones, still get sound.
    Depending on what you've got Settings > General > Use Side Switch To set to (mute or rotation lock), then you can mute notifications by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085

Maybe you are looking for

  • [Solved] Startx won't work! Laptop issues.

    Okay, here is what Ididin as much detail as possible. Dual boot: Windws XP + Archlinux the partition is like this 80 GB XP 80 GB arch      *10 GB root      *70 GB /home Video Card: nVidia Geforce Go 6100 Okay, so after I installed, I decided to and u

  • WL 7.02 Clustering service

              I 2 WL 7.02 servers. 1 Admin server, with 2 Managed servers. I have the Node Manager           and the Admin Server running as W2K services that start automatically. After a           reboot I can login to the Admin Console and Start the Cl

  • Dual Monitor alignment

    I have 2 Apple Aluminum framed Apple 30" monitors. With my 2007 MacPro, the graphics card supported two DVI attachments. The monitors were aligned...a window spanning both monitors was perfectly straight. My new 2010 MacPro (with the ATI Radeon HD 58

  • How to backup sent & received email using thunderbird?

    hi all i want to backup my entire email includes inbox & sent item from thunderbird, but i dont know how? please help me! tqsm rahim

  • Orginizing your library by arist name.

    Im trying to organize my library by artist name. When I do the the names that start with numbers (ex. 50 Cent, 2Pac, Etc) our on the bottom. When I put them on the top the Z's come after. Is there any way where i can put these names that begin with n