Script to make an object the size of the artboard.

I'm looking for help to try to be a subject of the exact size of the artboard.  It's something I do on a daily basis for many different reasons, and it would be very useful if this can happen automatically for any size would be the artboard.  If I understand the only way is a script but I have no experience with no shooting scripts illustrator, im certainly no programmer.  I put in place in the past to copy since the entries on the artboard when you are on the work plan tool, but these rounds to la.01 the closest quickkeys and is not sufficiently precise so that I work with.  Also, if I do this with several pages open illustrator is very slow to respond to the work plan tool.  If anyone has any idea where to start or saw these other scripts I'd be very happy.  Thank you.

Here is a script that I've seen here that I believe can contain what I need but now knowing I have no idea where to start on changing the programming.  All I need is the part where an object is placed on the artboard that is the same size as the artboard.  If someone can advise on editing I 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;
}

Here you go, select an object before you run, if your art is more than an object, first make a group.

#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;

                    sel.width = docw-deltaX; // width is Geometric width, so we need to make it smaller...to accomodate the visible portion.
                    sel.height = doch-deltaY;
                    sel.top = docTop; // Top is actually Visible top
                    sel.left = docLeft; // dito for Left

          }
else
          {
                    alert("select ONE object before running");
          }

Tags: Illustrator

Similar Questions

  • Repeat for each issue of the artboard

    I have a script that makes guides around the edge of the artboard. It works great when you only have a single work plan, but has problems when there is more. You can see what's not here?

    #target illustrator
    var docRef = app.activeDocument;
    var artboardRef = docRef.artboards;
    
    //repeat for each artboard
    for(i=0;i<artboardRef.length;i++){
    
      //get artboard size
      var left=artboardRef[i].artboardRect[0];
      var top=artboardRef[i].artboardRect[1] ;
      var right=artboardRef[i].artboardRect[2] ;
      var bottom=artboardRef[i].artboardRect[3] ;
    
      //create lines
      var lineLeft = docRef.pathItems.add();
      var lineRight = docRef.pathItems.add();
      var lineTop = docRef.pathItems.add();
      var lineBottom = docRef.pathItems.add();
    
      //set line points
      var leftmargin = (72);
      var rightmargin = (72);
      var topmargin = (72);
      var bottommargin = (72);
      
      //set line points
      lineLeft.setEntirePath([[leftmargin, 0], [leftmargin, bottom]]);
      lineRight.setEntirePath([[right - rightmargin, 0], [right - rightmargin, bottom]]);
      lineTop.setEntirePath([[0, 0 - topmargin], [right, 0 - topmargin]]);
      lineBottom.setEntirePath([[0, bottom + bottommargin], [right, bottom + bottommargin]]);
      
      //make lines guides
      lineLeft.guides = true;
      lineRight.guides = true;
      lineTop.guides = true;
      lineBottom.guides = true;
    
    };
    

    you have coded hard '0', it should be changed to variables, otherwise, it will point to the same x or is coordinated

     //set line points
      lineLeft.setEntirePath([[left+leftmargin, top], [left+leftmargin, bottom]]);
      lineRight.setEntirePath([[right - rightmargin, top], [right - rightmargin, bottom]]);
      lineTop.setEntirePath([[left, top - topmargin], [right, top - topmargin]]);
      lineBottom.setEntirePath([[left, bottom + bottommargin], [right, bottom + bottommargin]]);
    
  • How to create a box the size of the artboard without the help of a script

    HI -.

    Is there a way to create a box to the size of the artboard automatically, without the help of a script? FOR EXAMPLE. something I can build in action. Ive been able to create the box using a script, but we can not save the script in action, so unfortunately that there's no help for me

    What I want to do is

    1 open the file

    2 create box with no filling, no race, making the size of the box of the artboard

    3. run the rest of an existing action

    Greatly appreciate any help, I want to run on more than 10,000 cases per year.

    Using slices may be slightly inaccurate, Carlos (no offense intended).

    Here is another approach:

    Rectangle_Artboard_Size.AIA - Google Drive

    The action was created in Illustrator CS5, so no guarantee that it works in CC2015.

    Two prerequisites are necessary:

    -Alignment on work plan should be on (pallet alignment).

    -L'option divide and outline will remove unpainted work should be disabled (see Options Pathfinder).

    In older versions of Illustrator (I think of CS3), we could make a simple gesture of the 2 step using the object > acreage > make order, then the cultivated area > Release. It is not possible in recent versions of Illustrator.

  • Scripting VI - implementation order of the objects in the public Service

    I have an application where I use VI scripting to move things around, on the façade of a bunch of VI s to conform to the coding guidelines.  One of the problems I have is that some objects are above other objects (when what they are supposed to be behind other objects).  I can't try to understand how to use VI script to make a point about the FP at the top (or back) another object (LV2012sp1).

    Any help?

    Thank you


  • In the Powershell script execution error: could not find the type [ordered]: make sure that the assembly containing this type is loaded.

    People,

    I am trying to load and run the PowerShell script of PowerCLI Module to check the CPU, memory and storage overcommitment. VMware PowerCLI Blog - VMware Blogs but somehow it is always stopped with the error: cannot find the [ordered] type: make sure that the assembly containing this type is loaded.

    Here are some of the diagnostic result:

    $PSVersionTable

    Value name

    ----                           -----

    PSVersion 2.0

    PSCompatibleVersions {1.0, 2.0}

    BuildVersion 6.1.7601.17514

    PSRemotingProtocolVersion 2.1

    WSManStackVersion 2.0

    CLRVersion 4.0.30319.1026

    SerializationVersion 1.1.0.1

    Get-ChildItem ' HKLM:\SOFTWARE\Microsoft\NET frame Setup\NDP'-recurse |

    Get-ItemProperty-name of the EA - 0 Version |

    Where {$_.} PSChildName-match ' ^ (?) (S) \p {L} "} |"

    Select PSChildName, Version

    PSChildName Version

    -----------                       -------

    v2.0.50727 2.0.50727.5420

    3.0.30729.5420 v3.0

    Windows Communication Foundation 3.0.4506.5420

    Windows Presentation Foundation 3.0.6920.5011

    3.5.30729.5420 v3.5

    Customer 4.0.30319

    4.0.30319 full

    Get-PowerCLIVersion

    PowerCLI Version

    ----------------

    VMware vSphere PowerCLI 5.8 Release 1 build 2057893

    ---------------

    Versions of the snap

    ---------------

    Build VMWare AutoDeploy PowerCLI component 5.5 1983942

    Build VMWare ImageBuilder PowerCLI component 5.5 1983942

    Build license of VMware PowerCLI component 5.5 1265954

    Build VMware Storage PowerCLI component 5.8 2057894

    Build VDS's VMware PowerCLI component 5.8 2031581

    Build VMware vSphere PowerCLI component 5.8 2031581

    I installed Windows6. 1 -KB2819745- x 64 - MultiPkg.msu to enable Powershell v4.0 on my Windows 7 laptop, but still the script cannot be executed with the above error message.

    Any kind of aid and assistance would be greatly appreciated.

    Thank you

    Hello-

    Ah, yes--it is that review.

    Another option, because you are not able to go to .NET FX 4.5, is to remove the parts "[ordered]' of the code that you use.  This type Accelerator makes the hash table a dictionary sorted.  The effect to remove that from the code will be that the properties of the object that results will not be in the order in which they appear in the code.

    And, another option would be to install PowerShell v3 (the version in which the '[ordered]' feature has been added').  That shouldn't require a FX .NET newer than what you showed as having already installed on this computer.  However, as we have seen with the PSSnapin and PSv4 Exchange, you want to make sure that the PSSnapins / Modules you want to use are compatible with PowerShell v3.

  • How make an object appear at a specific time in the timeline?

    I know this is a stupidly simple question but I can't do this work.

    I want to put more than one symbol on the stage at the same time, but I want them to appear at different times.

    Whenever I have paste the symbol on the stage, however, it always seems at the start of playback.

    I have the image auto key button checked, but it seems to make no difference to the result.

    This frustrated beginner, you will appreciate any help please. I'm used to Flash, where you place a blank Keyframe on the scene then paste your object right there in the script simply.

    1. Select the item.
    2. Move the playhead where you want to raise objection to appear
    3. Select the display on the top left panel and choose from the list - what is before the will have screen. You can enable and then view or disable as needed.
  • Is it possible to modify this script to make same width or height objects?

    I found this script that makes the objects selected from the same width AND height. I am very new to scripting. is it possible to change this to an object of the same width, leaving their heights the same?

    mySelection = activeDocument.selection;

    If (mySelection.length > 0) {}

    If {(mySelection instanceof Array)

    goal = mySelection [mySelection.length - 1];

    for (i = 0; i <(mySelection.length-1); i ++) {}

    ratioW = 100/(mySelection[i].width/goal.width);

    ratioH = 100/(mySelection[i].height/goal.height);

    mySelection [i] .resize (ratioW, ratioH)

    }

    }

    } else {}

    Alert ("nothing selected!")

    }

    Thanks in advance

    Yes,

    change this line

    ratioH = 100/(mySelection[i].height/goal.height);
    

    for this

    ratioH = 100;
    
  • Foglight initialize a command on the PC and run a script that makes a sound or a banner on hold the workstation?

    How can we get foglight to invoke a command on the pc and run a script that makes a noise or a banner on my computer

    http://en.community.Dell.com/TechCenter/performance-monitoring/Foglight-administrators/f/4788/t/19552156#14120

    The question really selectively running a sound in a JavaScript browser session, do not turn something local on the user's PC.  The Sonic equivalent of an animated GIF as an analogy.

    The most difficult part, in Java, play a sound through various types and versions of browser without opening a 'player '.  This has been an incredibly difficult task by Oracle, on behalf of the whole being.  If you really want to dive into it, here are some links:

    http://docs.Oracle.com/javase/7/docs/TechNotes/guides/sound/programmer_guide/contents.html

    One approach that seems to have some promise for very small sound files is:

    http://stephengware.com/projects/soundtoclass/

    I got no time to mess around with it yet.

    This seems to have some promise, but still once, have not figured out how to operate:

    import java.awt.Toolkit

    Toolkit.getDefaultToolkit () .beep)

  • How to export a PDF file to make nonprinting objects show but don't print not AND hyperlinks on the top of the page work at the same time?

    Firstly - I work in InDesign CC 2015.

    My problem is, I had this 10 page document, which, on every page, shows an object that must be in PDF format - but do not print. I made this object into a button and unchecked "Printable". On top of this object, I made 10 hyperlinks (separate layer) that point to the page 1-10.

    When you export the document and I use the interactive PDF format , works ' show nonprinting object but do not print ' well, BUT hyperlinks don't. If I uncheck the "layer of nonprinting objects" in the file PDF, then hyperlinks work, but the problem now is that the nonprinting objects are invisible...

    When you export the document and I use a PDF to print the "unprintable object show but do not print" does not work BUT the hyperlinks don't...

    I put hyperlinks to post a link to pages and also tried the link to the anchor text. No difference.

    So my question is: How to export a PDF file to make nonprinting objects show but don't print not AND hyperlinks on the top of the page work at the same time?

    Thank you

    Mette from Denmark

    I swapped my links to the buttons - AND NOW IT WORKS; (o)

  • How to make an object to rotate when it moves up and down or left and right of the key to the other?

    How to make an object to rotate when it moves up and down or left and right of the key to the other?

    Just animate the rotation property, you animate the position property of the same way.  Very easy.

  • Very new to photoshop, I try to make changes to a photo and set up as a dynamic object, but after the selection of dynamic object, the grid appears and my photo dissppears

    Very new to photoshop, I try to make changes to a photo and set up as a dynamic object, but after the selection of dynamic object, the grid appears and my photo dissppears

    Well, something's wrong with Photoshop. Try to close Photoshop, and then press Command + Option + shift as you restart Photoshop. You will be asked to clear the Photoshop preferences. ATTENTION: you will lose all current preferences.

  • How to make an object follow the mouseX when clicked on

    How to make an object follow the mouseX if clicked? Help, please.

    You should think it through - your code does not match your very simple explanation of what you say, it should do so, and it should... click an element and follow the mouse.

    A game loop (ENTER_FRAME) could work, but in this case it wastes unnecessary treatment if the mouse does not move.  And in your code example, it does not expect the clicks.

    Use a MOUSE_MOVE instead of an ENTER_FRAME event listener.  Inside of the event by clicking on the handler function is where you must be defined the MOUSE_MOVE listener.  The MOUSE_MOVE listener Manager is where you assign rock1Cnt.x = mouseX.

    public void Main (): void {}

    rock1Cnt.addEventListener (MouseEvent.CLICK, mouseClickHandler);

    }

    private void mouseClickHandler(e:MouseEvent):void {}

    stage.addEventListener (Event.MOUSE_MOVE, followMouse);

    }

    private void followMouse(e:MouseEvent):void {}

    rock1Cnt.x = mouseX

    }

  • How to make an object on the master always appear in front on my pages?

    I can't seem to find a way to make an object on my master to always appear in front on my pages. I watched a video on lynda.com muse essentials and it says to select the master then select the object, then go to the tab object in the menu and select move to which I did and it just shows a greyed out layer1, on video, he showed moveto > master forefront

    Thank you

    Morgan

    Refer to a similar thread here - http://forums.adobe.com/message/5581528.

    You just need to move the content of your master page to the top layer of most in the layers panel. And the content of the pages of content in the other layers to be able to manage easily. This shoud keep the contents of the master page at the top.

    The option "move to" is abandoned since we launched a workflow overall better to arrange the objects using layers - http://helpx.adobe.com/muse/tutorials/layers-muse.html.

    Thank you

    Vinayak

  • How to make an object out of the screen?

    Hello everyone!

    I create a game introduction with Flash pro CS6 and here is my problem.

    I want an object in my animation to exit the screen, but I don't know how to do it.

    Is there for example, that a way of defined work area, so that when I do something out of this area, it does not appear in my final animation (regardless of the format, .avi, .mov, spritesheets...) or may be "cut" (if I make my object inside the arear half-and-half work outside)?

    Is there another way to do this?

    Thank you!

    With the help of a mask can be a way.

  • Layer mask groups converted from work plans to the size of the artboard in older versions of Photoshop

    I wanted to start this post as an idea, but I couldn't choose communities (it wouldn't let me), so here it is posted...

    ----

    Just came across this with a customer...

    I use for a mobile design project work plans, and I just got a screenshot with some texts asking why among work plans were really great. Way bigger than a phone. (I'm under NDA and cannot post the screenshot, but imagine there are a lot of iPhone size work plans and two of them seem to be at a right angle)

    I opened the file and on my end, everything is the right size. Remembering the weeks ago to tell the customer that they need to update their version of Photoshop for all this work correctly, I have take a look at the screenshot and see that they are on CC2014 - none of the work plans.

    What I'm asking here, is that, since we have data, plans of work are objects of a defined size and 'alive', why not just use these data to hide layer groups at the opening of the PSD / PSB (PSB in my case) in older versions of Photoshop?

    It could save you a TON of hassle and confusion.

    Hi Zack,

    High level to your query response is: no, there is no conduct business case for a general solution to what you are suggesting. So I don't see what is happening.

    I say that as someone who likes to give back and forth and backward compatibility.

    There are two parts of the problem that you raise. They are related and somewhat intertwined.

    1. Having the version previous (2014) do something reasonable with the data from the version the most recent (2015). Either the old version should be taught on the most recent data so it can make a decision about what to do, or the newer version must put additional data in the file format for consumption by the older version.
    2. Back and forth between versions. As you say, a much more difficult problem. In fact, we do a good job of that today. But we must be sure that whatever we do for (1) not to damage and back the wrong way.

    Let's be very clear: 2014 will not be touched, except for critical bugs, absolutely. And even before 2015 is released, it would have not been corrected to make it behave better with work plans. There is no way that I could see what is happening. So all we have done for better backward compatibility had to be entirely done within 2015.

    For the round trip, the general problem is something like this: we want to 2014 to read an object that has properties of 2015, he does not understand. While we might learn ch to keep these properties as opaque property, must also have rules for when these properties are not valid and thrown on the floor. Probably, if the object is changed. But not always. And sometimes when another object parent is changed. And so on. Right now, we destroy them unknown content from their reading in the old version. Make us and record what we understand. As a user, you receive an alert telling you that we are do this. It's the safest thing to do.

    There are special cases where a developer can see an opportunity to preserve a level of backward compatibility and back and forth. We try to do if we believe that it is safe. But this scenario happens only occasionally.

    In the case of work plans, made us really think about this: If we added a mask to the group for backward compatibility, it should do something with this mask reading around 2015. And what would happen if the user edited this mask in 2014 and opened upward in 2015 - and who edited mask do not align with the structures of the artboard? Things started to get dark quickly. We started to see traps. The workflow together to sheath special round trip had to be tested and verified. The cost was rising and this expense must be filtered through a cost/value trade-off. And then what happens when we add a new property to the structure of work plan? At these efforts for nothing?

    So we compromised with what you have today. Work plans become groups in 2014. The Group and the layer structure remains intact. Doesn't secretly add us and remove masks for the round trip. You can safely change the groups to your heart's content. When return you this document in 2015, you redo the work plans of the groups. Was not clear and safe way to do more than that given the time that we had.

    Take a step back and think about your problem, it doesn't seem to be a value to a script that converts group work plans + layer masks for your workflow to have your documents that is consumed by the customers of 2014. This would be carried out in 2015 because she would need understand the work plans. And maybe vice versa from 2014 to 2015, assuming that the documents were not published in a hostile way. We're not likely to write such a script as a generic tool, but someone competent with script might be able to do this.

    More that I intend to write, but hopefully, it gives you additional insight in the compromises that we have faced.

Maybe you are looking for