Create guides in Illustrator CS4 JS

Hi, I need to create 4 guides in Illustrator page 3/16 inch from each edge of the artboard using javascript.
Could someone help me.
Thank you very much.
Yulia

Joe, I think that this should be pretty close to what you want. It looks for path items in the selection, then should check to see if its a rectangle if it is then inset guides 3mm. I think it needs a check for right & left direction control points but I have NOT the time at the mo.
#target illustrator
var docRef = app.activeDocument;
// Convert mm to points
var thisOffset = 3 * 2.834645;
with (docRef) {
// Get selected items Array
if (selection != '') {
for (var i = 0; i < selection.length; i++) {
// Check if its a path item
if (selection[i] instanceof PathItem) {
// This might need a better test!!!
if (isRectangle(selection[i])) {
// Ignore any stroke values
var thisPath = selection[i].geometricBounds;
// Calculate guide box
var guideTop = thisPath[1] - thisOffset;
var guideLeft = thisPath[0] + thisOffset;
var guideWidth = (thisPath[2] - thisPath[0]) - (thisOffset * 2);
var guideHeight = (thisPath[1] - thisPath[3]) - (thisOffset * 2);
// Make new rectangle
var myGuides = pathItems.rectangle(guideTop, guideLeft, guideWidth, guideHeight, false);
// Make it guides
myGuides.guides = true;
} else {
alert('A Path Item was NOT a rectangle?');
} else {
alert('An object was NOT a Path Item?');
} else {
alert('You have NO selected objects?');
function isRectangle(pathObject) {
with (pathObject) {
if (pathPoints.length != 4)  return false;
if (pathPoints[0].anchor[0] != pathPoints[3].anchor[0]) return false;
if (pathPoints[1].anchor[0] != pathPoints[2].anchor[0]) return false;
if (pathPoints[0].anchor[1] != pathPoints[1].anchor[1]) return false;
if (pathPoints[2].anchor[1] != pathPoints[3].anchor[1]) return false;
return true;

Similar Messages

  • Illustrator CS4 - Saving Buttons Created in Illustrator CS4

    How do I save a created button in Illustrator cs4 without the whole page - just the button - it was straightforward in illustrator CS3.

    I don't understand your question. In all version of Illustrator you always save the whole page. Do you mean Export? What format? How are you exporting? Are you using Save for Web? Did you turn off Crop to Artboard? Have you tried resizing the artboard to the size of hte button?
    Also, the whole purpose of this forum is to provide help for users of Illustrator. Please try to include some hint about your problem in the title of your post. Imagine if everyone did what you did, calling their posts "Illustrator CS" or "Illustrator CS3". How much fun would it be to go back and check your responses, when there are dozens of posts with the same title?

  • User can't open a PDF created with Illustrator CS4

    I'm creating a PDF in Illustrator CS4, and I save it on a server where the user can get it. User is not able to open the file, it says acces denied. When I email that same file to several users, they can open it without a problem. I have checked that there's no restrictions on accessibility on the folder or the file. I wonder if it has to do with windows user permissions...
    Our IT guy couldn't find any problem ....
    Any clue?
    G

    Try saving locally and copying to the server.

  • How to create guides for a responsive website in illustrator

    Does anyone know of any illustrator plugins that will generate customized guides?  I'm looking for something like you can do in InDesign with its Create Guides feature.
    Thanks,
    Paul

    Draw a rectangle and then Objct > Path > Split into grid.
    Don't forget to check "create guides"

  • How can you create a swatch from a jpeg in Illustrator CS4?

    I am trying to create a jpeg image into a swatch in Illustrator CS4. In previous versions you could simply drag the image into the swatches toolbar and it would convert it automatically. Now when I do that nothing happens. When I click on new swatch it creates a colour swatch instead of the actual image itself.

    When you say you would drag the image itself into the Swatch Palette and it would show the image itself? How would then use this swatch? Can you give an example of what you would apply a jpeg to as a swatch? The only palette that I can think of off the top of my head that you can drag a jpeg into and have the icon appear as the jpeg is the Symbols Palette. Is is possible that you were using the Symbols Palette in the past and not the Swatch Palette?

  • How to create unique shapes in Illustrator CS4

    First off....
    I am new to the Adobe suite of applications and also new to owning a Macbook Pro. I have been using a design program for Windows for many years.
    I would like to master the creation and manipulation of shapes using Illustrator CS4.
    As one example, how would I create the following:
    I want to end up with a shape that is similar to one-quarter of a full moon.
    Using my Windows program (not an Adobe product), I would create a line using a line tool, and then I would be able to convert that line to a curve using a shape tool, which would enable me to drag from the midpoint of the line and have it become an arc. Then, while still using the shape tool, I could click once to select one of the endpoint nodes to then click on an "auto-close" option which would add a straight-line edge to close the shape for outline and fill purposes (so one side of the shape is straight at this point and the other side is curved). Using the shape tool, I would double-click near the midpoint of the straight edge to add a new node to the shape, and then I would use the "convert to curve" option from within the shape tool to be able to drag this straight side towards the curved side to end up with the quarter-moon shape as desired.
    How would I make this sort of shape using Illustrator, and as a general question for learning, how can I learn all about how to put lines in the design space for purposes of joining these lines, curving any part of one or more lines and then filling or outlining the finished shape made from joined lines?

    > and as a general question for learning, how can I learn all about how to put lines in the design space for purposes of joining these lines, curving any part of one or more lines and then filling or outlining the finished shape made from joined lines?
    Well, you can read the documentation. That will be much more thorough and methodical than asking a random series of "how do I..." questions in a user forum. And it will take you
    a lot less time.
    > Using my Windows program (not an Adobe product)
    You can say the name. If there's actually anyone here who doesn't know other drawing programs exist, well, they
    need to. Your description sounds like Xara Xtreme.
    > I want to end up with a shape that is similar to one-quarter of a full moon..create a line...convert that line to a curve...drag from the midpoint of the line and have it become an arc...select one of the endpoint nodes... "auto-close"...double-click near the midpoint of the straight edge to add a new node..."convert to curve"...drag...
    A similar procedure could be used in just about any vector drawing program that draws cubic Bezier curves. A much quicker procedure could also be used in just about any program, by leveraging the geometric shape tools and path combination commands that are just as ubiquitous:
    1. Draw a circle.
    2. Duplicate the circle.
    3. Overlap the circles partially.
    4. Use one circle to "punch" the other, leaving the difference (the crescent shape).
    Here are two AI-specific differences I note in your description:
    Illustrator can't bend a straght segment by dragging its middle if the straight segment has both its associated curve handles retracted. Dragging such a segment in AI just moves the segment (and its associated anchorPoints).
    Illustrator displays fills on open paths. There is no option to turn off that often unwanted behavior.
    Again, read the manual (the online Help files). It will take you decades to learn the program by asking random questions on the basic use of the tools, location of commands, organization (well, disorganization) scheme of the program, etc., etc.
    JET

  • Creating spot color in Illustrator CS4 js

    Hi,
    I need to create spot color in Illustrator CS4 with js, with assigned name and color values. Here what I have:
    myColor = myDoc.spots.add({name:"FOIL", colorValue:[10, 0, 100, 0]});
    But it comes out as process instead of spot and the color is not assigned.
    Thank you for your help.
    Yulia

    the add function has no parameters, you have to add them after
    addSpot ('FOIL', 10, 0, 100, 0);
    function addSpot(name, c, m, y, k) {
        try {
            swatch = app.activeDocument.swatches[name]; // if swatch exists....
            addSpot (name+='1', c, m, y, k); // ...add 1 to swatch name
        catch (e) {
            var newSpot = app.activeDocument.spots.add();
            newSpot.name = name;
            var newColor = new CMYKColor();
            newColor.cyan = c;
            newColor.magenta = m;
            newColor.yellow = y;
            newColor.black = k;
            newSpot.colorType = ColorModel.SPOT;
            newSpot.color = newColor;
            var newSpotColor = new SpotColor();
            newSpotColor.spot = newSpot;

  • Can files created in cs5.5 design premium be saved so they open in Photoshop CS2 or Illustrator CS4?

    Can files created in cs5.5 design premium be saved so they open in Photoshop CS2 or Illustrator CS4?

    Yes, you can save compatible files as long as you obey the rules like not using unsupported features such as nested groups, per group clipping masks, smart objects and several other things in Photoshop and use the "Maximize Compatibility" option. Illustrator will simply expand the appearance of objects or rasterize/ flatten them when going back to older versions if a feature is not available or changed in those old versions.
    Mylenium

  • Help to create outlines using javascript in adobe illustrator cs4

    Hi,
    Please help me to create outlines using javascript in illustrator cs4.
    Thanks
    Karthik

    The textFrame object has a createOutline() method. So if you are wanting to save a version of your file that will not require fonts then loop thru these items in your document… (Loop backwards btw its easier that way) Take a look at the other posts at the top here as others are wanting to do the same thing… If your document is more complex then you may need to iterate all the way though which takes a bit more work…

  • Illustrator CS4 opens but won't create a new document

    Hi,
    I've got an Illustrator CS4 problem. I can launch Illustrator CS4 and it launches quite happily. However, when i create a new document nothing happens. When I open a document nothing happens. I'm a local admin on my PC. It's running Windows XP SP3. I've re-installed Illustrator to see if that fixed the problem but it didn't. I have Photosop CS4 on and it opens documents etc without a problem.
    Cheers
    Steven

    If you cannot create new docs, it doesn't see its templates, most likely. For whatever reason they are either really not there or simpyl blocked by the operating system due to permission issues. At least one of them must exist or else the dialog won't open up. Check the program directory (C:\Program Files\Adobe\Adobe Illustrator CS4\Support Files\Required\New Document Profiles) and your user home directory. Other than that it could of course always be more generic graphics card problems...
    Mylenium

  • A few new Illustrator CS4 questions.

    Weird, I just can't figure these out.
    First, how do you change the document size/orientation when it's already open? This seemed to be a cinch in all other versions of Illustrator, but now... the new Document set-up menu is quite different.
    Related, how does one ADD or SUBTRACT art boards from a document? And remove the art board guides when activated?
    How does one prevent Illustrator from opening all documents/a new document, in the same window box, and instead in a separate window box?
    If these questions seem rudimentary, let me assure you that I might be having a spaz moment with the new CS4 version of Illustrator, but I've been using the program itself for 10+ years. Maybe I'm becoming lazy and/or senile?

    "I have a complex file I created in photoshop with many layers, containing
    gradients and blends with no background layer, cropped and feathered edges and
    100 opacity. I want to use this for a design in Illustrator CS4 but not at 100%
    as I want to type over the top and be able to read. If I simply change the
    opacity then the background color in illustrator changes the look of the PS
    file. I have tried everything I know, including going back to PS and changing it
    there, but the same results. What I ultimately want is a lighter version of the
    PS file that is not transparent and allows color behind it to affect the over
    vibrancy of the PS file. I'm sure there is a way, but since my knowledge is all
    self taught I just don't know the answer. Sure could use some help. Thanks
    R"

  • Artboards disappearing in Illustrator CS4

    I'm using Illustrator CS4 on Mac OSX 10.6 and have created a 12 page document for folks at work.
    Every time I re-open the document to make amends all but the first artboard have disappeared.
    All the artwork content is still there, layers are fine etc but where the outline of the artboard page was there are now only guides Which are added to a layed named 'Guides For Artboard'.
    When I create a PDF of this file it only does the one, first page. It's like it doesn't realise the rest of the pages exist.
    But this doesn't happen to every document. It keeps happening to this one, it's happened to others but then when I open them again later they are fine.
    Is this a bug??
    This file was created new in CS4 and is only edited by myself on the same machine.
    Any suggestions would save me some serious grief!!
    Ta

    No it's saved as a CS4 ai file.
    But that did get me wondering, so I saved it as a AI CS3 file and upon reopening that it's done the same thing, added guides where my artboards were.
    That makes sense as CS3 doesn't support multiple artboards.
    But I am saving all my artworks as CS4 files and it's doing this to some of them which is what I don't understand.
    Just wondered if there was a setting i'd missed or something

  • Illustrator CS4 Script

    Hi.
    I am creating a script for Illustrator CS4 using Word VBA.
    When I execute the following code,
    I get an error ,that is "ActiveX component can't create object".
    Set app = CreateObject("Illustrator.Application")
    This code works well on Illustrator CS2, but not on CS4.
    I don't know why this error occured
    Can some give me any advice?
    Best Regard.
    erieru103http://forums.adobe.com/people/erieru103

    Hi.
    My script works by using CreateObject("Illustrator.Application.CS4").
    Thank you for your advice.
    The scripting guide says
    "If you have multiple versions of Illustrator installed on the same machine and use the CreateObject
    method to obtain an application reference, using "Illustrator.Application" creates a reference
    to the latest Illustrator version. To specifically target an earlier version, use a version identifier at the
    end of the string..."
    There was CS3 version installed on my PC.
    Before installing CS4, I have unstalled CS3.
    Why the error occured??
    Best regard.
    erieru103

  • Create guides

    Hi,
    i'm new to Illustrator CS4 and i need to used it at work.
    I was wondering with i'm not able to create new Guides with keyboard shortcut.
    in settings it is set for CTRL+5... but in the menu View > Guides > Make Guides it is disabled (grayed).
    any idea ?
    thanks a lot.
    A.

    >so how do you call the blue guides that you can create by dragging from ruler ?
    They are called guides.
    I am unaware of a keyboard shortcut in Illustrator (through version 12) that enables you to create guides merely by entering coordinates.
    Vertical and horizontal guides pulled from the ruler can be unlocked and moved. Once unlocked (and selected), they can be individually positioned numerically by entering x or y value in the transform palette/panel or control palette/panel. (Remember to re-lock!)
    Holding down the shift key while pulling out guides will make them snap to ruler increments.
    You might be able to write actions to automate some of this and add keyboard shortcuts. However, if you have a set of guides you re-use often, a template might be a better solution.

  • Macbook Air 11" i7 corrupt files problem with Adobe Illustrator CS4

    Hi
    this problem may not be entirely related but maybe someone could help anyways or knows how I can proceed...
    I'm running Illustrator CS4 on a Macbook Air 11" (latest 2011 model, with i7, 4GB, 128SSD), and lately some files are getting corrupted. specifically, adobe illusrator CS4 files with weeks of work. interestingly, the time machine backups are also getting corrupted.
    its like I'm working on a file for a few days, backing up with time machine as well
    closes the file, after a few days returns to it… (normal behavior)
    then when i try to get back to the file then sometimes it says "Cant open the illustration, could not complete the operation" and opens a blank canvas.
    restoring the file via time machine also gives the same error (its like all versions get corrupted simultaneously), even 4-5 versions backwards, even though they worked before when the file worked
    it happened quite a few times, ruining weeks of work.
    I tried the following:
    reinstalling CS4 - didn't work
    Opening the files on CS5 - still don't open
    doing the file recovery thing and then opening it in a notepad - didn't work at all
    using Time machine - the files are still corrupt
    it only happenes with AI files, not photoshop files, for example.
    I thought maybe it has anything to do with SSD? since my previous macbook pro (15", 2007) never did these errors…
    please help
    Eido

    If at all, this would be I/O performance and bandwidth issues with Time Machine, but I don't think that's the problem. More to the point I think that it's a case of Preview opening the files to genereate thumbnails and icons and something going wrong there. I'd look up some guides on how to edit the relevant plist and conf files to exclude your AIs or turn off the behavior to generate these previews globally. This may help hugely...
    Mylenium

Maybe you are looking for