Start a new Document with Millimeters

Hi there,
I am new to Illustratror Scripting.
I changed a Script from William Ngan, http://www.metaphorical.net and http://forums.adobe.com/message/3813716?tstart=1
It saves EPS-files instead of AI-Files. But the Units are still in PT. I want them to be in Millimeters and the artboard isn't focused on the viewport.
I suppose it's RulerUnits.Millimeters but somehow it doesn't work and when I pick a line it shows pt. I don't know how to write it. Perhaps you find the solution.
I deleted the Comments of William so it's not as long as the original. I tried at the line:
var newdoc = app.documents.add ( doc.documentColorSpace, doc.width, doc.height );
I thought this would help:
newdoc.RulerUnits = doc.RulerUnits;
But it doesn't work. Hope it shows the idea.
/* Here the Script starts */
var doc = app.activeDocument;
var docname = (doc.name.split('.'))[0]; // name
var doc_artboard = doc.artboards[0].artboardRect;
if (app.documents.length > 1) {
        alert( "Nur ein Dokument darf geöffnet sein. Schließen Sie andere Dokumente und führen Sie das Script erneut aus.");
} else {
    var ok = confirm( "Bitte speichern Sie zuerst Ihr Original.\nDie Ebenen werden im gleichen Ordner wie Ihre Datei gespeichert.\nWeiter?" );
    if (ok) {
        // prepare layers
        for(var i=0; i<doc.layers.length; i++) {
            doc.layers[i].visible = false;
        // go through each layers
        for(var i=0; i<doc.layers.length; i++) {
            app.activeDocument = doc;
            if (i>0) doc.layers[i-1].visible = false;
            doc.layers[i].visible = true;
            doc.activeLayer = doc.layers[i];
            saveAI( doc.path, doc.activeLayer.name, i );
        // close original file without saving
        doc.close( SaveOptions.DONOTSAVECHANGES );
function saveAI( path, name, id ) {
    var currlayer = doc.layers[id];   
    var g = currlayer.groupItems.add();
    group( g, currlayer.pageItems );   
    var t = g.top;
    var l = g.left;
    var myPreset = app.getPresetSettings("Druck");
    app.documents.addDocument("Druck", myPreset );
    var newdoc = app.documents.add ( doc.documentColorSpace, doc.width, doc.height );
    newdoc.artboards[0].artboardRect = doc_artboard;
    /* app.preferences.rulerUnits = Units.Millimeters; */
    /* app.activeDocument.rulerUnits = RulerUnits.Millimeters; */
    /* newdoc.Units = RulerUnits.Millimeters; */ 
    var newlayer = newdoc.layers[0];
    g.duplicate( newlayer, ElementPlacement.PLACEATBEGINNING );
    newlayer.pageItems[0].top = t;
    newlayer.pageItems[0].left = l;
    path.changePath( name+".eps" );
    var saveOpts = new EPSSaveOptions();
    /* saveOpts.compatibility = ILLUSTRATOR16; */
    saveOpts.embedLinkedFiles = true;
    saveOpts.includeDocumentThumbnails = true;
    saveOpts.embedAllFonts = true;
    saveOpts.saveMultipleArtboards = false;
    saveOpts.cmykPostScript = true;
    saveOpts.preview = EPSPreview.TRANSPARENTCOLORTIFF;
    newdoc.saveAs( path, saveOpts );
    newdoc.close( SaveOptions.DONOTSAVECHANGES );
    // wait for the new file to save and close before continue.
    // A callback function (if possible) will be better than a while loop for sure.
    while (app.documents.length > 1) {
        continue;
function group( gg, items ) {
    var newItem;
    for(var i=items.length-1; i>=0; i--) {
        if (items[i]!=gg) {
            newItem = items[i].move (gg, ElementPlacement.PLACEATBEGINNING);
    return newItem;

Muppet Mark and pixxxel schubser were totally right! I thank both of you!
Now it's time for me to share the working version. The Preset "Druck" is for the german version. It's "Print" for the international.
The Script saves layers as individual EPS-Files. The RulerUnits are Millimeters not Point. The viewport is still not focused on the Artboard when opening the document but that's ...
var doc = app.activeDocument;
var docname = (doc.name.split('.'))[0]; // name
var doc_artboard = doc.artboards[0].artboardRect;
if (app.documents.length > 1) {
        alert( "Nur ein Dokument darf geöffnet sein. Schließen Sie andere Dokumente und führen Sie das Script erneut aus.");
} else {
    var ok = confirm( "Bitte speichern Sie zuerst Ihr Original.\nDie Ebenen werden im gleichen Ordner wie Ihre Datei gespeichert.\nWeiter?" );
    if (ok) {
        // prepare layers
        for(var i=0; i<doc.layers.length; i++) {
            doc.layers[i].visible = false;
        // go through each layers
        for(var i=0; i<doc.layers.length; i++) {
            app.activeDocument = doc;
            if (i>0) doc.layers[i-1].visible = false;
            doc.layers[i].visible = true;
            doc.activeLayer = doc.layers[i];
            saveEPS( doc.path, doc.activeLayer.name, i );
        // close original file without saving
        doc.close( SaveOptions.DONOTSAVECHANGES );
function saveEPS( path, name, id ) {
    var currlayer = doc.layers[id];   
    var g = currlayer.groupItems.add();
    group( g, currlayer.pageItems );   
    var t = g.top;
    var l = g.left;
    var w = doc.width;
    var h = doc.height;
    var w = 31.1*2.834645;
    var h = 28.15*2.834645;
    var myPreset = new DocumentPreset;
    myPreset.width = w;
    myPreset.height = h;
    myPreset.units = RulerUnits.Millimeters;
    myPreset.title = docname;
    var newdoc = documents.addDocument( "Druck", myPreset);
    newdoc.artboards[0].artboardRect = doc_artboard;
    var newlayer = newdoc.layers[0];
    g.duplicate( newlayer, ElementPlacement.PLACEATBEGINNING );
    newlayer.pageItems[0].top = t;
    newlayer.pageItems[0].left = l;
    path.changePath( name+".eps" );
    var saveOpts = new EPSSaveOptions();
    saveOpts.compatibility = Compatibility.ILLUSTRATOR16;
    saveOpts.embedLinkedFiles = true;
    saveOpts.includeDocumentThumbnails = true;
    saveOpts.embedAllFonts = true;
    saveOpts.saveMultipleArtboards = false;
    saveOpts.cmykPostScript = true;
    saveOpts.preview = EPSPreview.TRANSPARENTCOLORTIFF;   
    newdoc.saveAs( path, saveOpts );
    newdoc.close( SaveOptions.DONOTSAVECHANGES );   
    // wait for the new file to save and close before continue.
    // A callback function (if possible) will be better than a while loop for sure.
    while (app.documents.length > 1) {
        continue;
function group( gg, items ) {
    var newItem;
    for(var i=items.length-1; i>=0; i--) {
        if (items[i]!=gg) {
            newItem = items[i].move (gg, ElementPlacement.PLACEATBEGINNING);
    return newItem;

Similar Messages

  • Starting a new document with just one new site?

    It seems that every little "site" I create ends up in the sites panel, cluttering things up.
    I would like to refer to old sites sometimes, maybe, but most of the time I just want to start fresh and think only about the site I'm working on.
    Is there a way to just have the current site in an iWeb document without seeing all the sites you've created back to the beginning of time?
    Thanks,
    doug

    If you're referring to just sites created in iWeb,
    consider using iWebSites. I use iWebSites</
    a> to manage multiple sites.. It lets me create multiple
    sites and multiple domain
    files.
    If you have multiple sites in one domain file here's
    the workflow I used to split
    them into individual site files with iWebSites. Be
    sure to make a backup copy of your Domain.sites files
    before starting the splitting process.
    This lets me edit several sites and only republish
    the one I want. This way each site is a separate
    file and can be handled separately.
    I think my problem is simpler than that. Rather than wanting to use iWeb as a website management tool doing something complicated like that, what I would like to do is use it as a web authoring tool - create pages, publish them to folders, and later open them open again if I want to change things. So each folder would have a "project" file associated with it I guess.
    doug

  • How to create a new document with a given theme, instead of choosing it every time.

    Hi,
    for work I only use a custom made keynote theme.
    I've already deleted all the default themes, and the only one that is listed in the app is the one I actually use.
    However every time I create a new document I have to chose its theme (that's normal having plenty of themes, but in my case is just a waste of time).
    I was wondering if there's a way to tell keynote to start a new document with a given theme, in order to avoid to chose it every time.
    Thank you for reading and for the help you will give.
    Giacomo

    Keynote > Preferences > General tab
    select “Use theme,” and then click Choose to select a theme.

  • Pages crashes when I try to start a new document.

    I can open saved documents.  I can edit documents. 
    When I try to start a NEW document the app crashes. 

    Hi beckynnate,
    First I would try under a test user to see if it's an App issue or a user (preferences) issue.
    Isolating an issue by using another user account
    http://support.apple.com/kb/TS4053
    That article has steps to try if it only happens with one account.  If it happens with both accounts, follow this article starting at "Remove receipts and reinstall iLife applications."  It talks about iLife, but iWork would be the same.
    iLife: Troubleshooting Basics
    http://support.apple.com/kb/ts3249
    Thank you for using Apple Support Communities.
    Nubz

  • HT200169 Having a problem with Logic 9 on a Mac Pro.Working on a lenghty song and apparently session got corrupted.Doesnt let me export tracks,program crashes.Already tried start brand new session with the tracks imported into it but still wont export.Sug

    Hello,having a problem with Logic 9 on a Mac Pro.Working on a lenghty song and apparently session got corrupted.Doesnt let me export tracks,program crashes.Already tried start brand new session with the tracks imported into it but still wont export.Suggestions?

    Thanks, Ian. Yeah, that's how I do it now...or with the controls in the left side pane. Still, I would have liked that quick on-the-spot edit capability...especially while sketching.
    Ian Turner wrote:
    Sorry Mark, you are out of luck as it does not do that - it works the same as L8. The way I would achieve that with more accuracy and control would be to route all the tracks you want to fade to a Bus then use volume automation on the bus. To do this you will need to add a standard audio track, then re-assign it using (Control Click on the track header) to the Bus track. You can then automate volume/plugins etc on the Bus track.
    Ian

  • Create a new document with settings appropriate for SWF or XFL output.

    I'm studying up for the CS4 ACE exam, and I'm stumped on something. In the "Laying out a Document" section, it says: "Create a new document with settings appropriate for SWF or XFL output." There isn't really anything specific to creating a document for flash, except that you wouldn't add bleed. I can't find anything online that addresses this. Am I missing something here? Any document can be exported to SWF or XFL. This seems rather ambiguous. What is there to know about this?

    You're right that any document can be exported to SWF or XFL. I'm not sure what you're going to be asked on the ACE exam, but here are some resources:
    Help topic:
    http://help.adobe.com/en_US/InDesign/6.0/WS2DECDF40-B6DA-40b6-804F-2703D6C6A460.html
    Tim Cole's first of 3-part series:
    http://blogs.adobe.com/indesignchannel/2008/11/indesign_2_flash_part_i_1.html
    My blog entry:
    http://blogs.adobe.com/indesigndocs/2009/03/exporting_interactive_indesign.html

  • Does anyone know why or what is the reason when starting a new iMac with Lion a gray bar sometimes appears when loading software?

    Does anyone know why or what is the reason when starting a new iMac with Lion, sometimes a gray bar appears under the Apple that begins to shade to dark as it loads OS?  It does this on occasion.  One time the system loaded was VERY slow and terrible colors.  Pulled the plug, re-started the computer and it did not do this.  As I say, its only on occasion, not every time.  I noticed in the discussion page there were problems listed for 10.6 nothing for Lion.
    Please advise, if possible.

    You should see this 4 option menu.  Click on Disk Utility:
    In Disk Utility, Select FIRST AID and then VERIFY and then REPAIR the disk.
    Ciao.

  • Cannot Start a new project with a mapped network drive

    When I try to start a new project with Encore and save the file to our network cluster (An Isilon Server), I get a file not found error message. When I try to do this to a local drive, it works just fine. None of the other Adobe products (Photoshop, Illustrator, After Effects) have this problem with this network drive.
    Greg Glaser

    Yes, it worked on the local drive, and also to a Windows Networked Server that was not the Isilon. Even after creating the project and moving it to the Isilon, it was generating error messages after a few minutes of use. The Isilon is using a BSD variant of Linux and Samba. The really strange part is the all other Adobe products from the Production Suite work with this server without any problems at all.

  • How do you delete extra "sheets" in numbers? Everytime I start a new document I end up numerous sheets.

    How do you delete extra "sheets in Numbers program? Everytime I start a new document it adds extra sheets..

    Hi Beast,
    You might find it easier to duplicate the whole doc and delete the sheets you don't want. Otherwise you are copying and pasting tables from each sheet.
    quinn

  • Getting Started: 01 Starting a new document | Learn Illustrator CS4 | Adobe TV

    Start a new document in Illustrator CS4 using the Welcome screen. Adjust settings in the New Document dialog box. Establish multiple artboards.
    http://adobe.ly/ySniK0

    Where are the files that are referenced in this video?

  • JS - Center Selection to Artboard / New Document with certain Artboard size

    TL;DR:
    how do I center my current selection to the artboard?
    just like hitting the "horizontal align-center" and "vertical align-center" buttons.
    Hi,
    I've been searching for the last two hours and before my head hits the keyboard I wanted to ask you for help.
    What I'm struggling with:
    in my init function i create a new document and then copy all layers from the previous document step by step to the new document and then save it as SVG.
    // Init
    (function(){
              destination = Folder.selectDialog('Select folder for SVG files.', docPath);
              if (!destination){return;}
              holderDoc = app.documents.add();
              stepThroughAndExportLayers(docRef.layers);
    my problem is that holderDoc = app.documents.add(); always creates a document that is not the same size as my initial document where the layers get copied from.
    so I want the exact same artboard size as in my initial document.
    I'm fine with either doing it as fixed values or taking directly the values of the inital doc.
    i tried this in the segment where I create the new document:
    // Init
    (function(){
      destination = Folder.selectDialog('Select folder for SVG files.', docPath);
      if (!destination){return;}
      holderDoc = app.documents.add();
      holderDoc.artboards[0].artboardRect = [0,0,128,128];
      stepThroughAndExportLayers(docRef.layers);
    and get this error message:
    "Error 1200: an Illustrator error occured: 1346458189 ('PARM')
    Line: 83
    -> holderDoc.artboards[0].artboardRect = [0,0,128,128];"
    which from what I've read on the web means that illustrator doesnt know what document to pick. but i have called it directly. so what could be the issue?
    to clearify: I do not want to fit the artboard to the images/layer. the artboard should always have a certain size. (for me 128px by 128px)
    I would highly appreciate you helping me with either fixing my approach or propose a completely new one.
    Thanks so much in advance.
    // edit: workaround
    (function(){
              destination = Folder.selectDialog('Select folder for SVG files.', docPath);
              if (!destination){return;}
              var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveArtboardIndex()];
              var ABRect = activeArtboard.artboardRect;
              holderDoc = app.documents.add();
              holderDoc.artboards.add(ABRect);
              holderDoc.artboards.remove(0);
              holderDoc.artboards.setActiveArtboardIndex(0);
              //stepThroughAndExportLayers(docRef.layers);
    i now added a new artboard to the new document with the same size as the artboard on the initial document.
    i remove the predefined artboard on the new doc and set the new artboard as active.
    BUT!
    the artboard is now not centered into the window. which lets illustrator place my image with ctrl+c -> ctrl+v somewhere outside the artboard.
    i now need to align my selection to the center of the artboard. but i cant find any reference on how to center a selection to the artboard.

    yes of course. i never modify the author's comments in original scripts.
    but I wont post the script anywhere when it doesnt work anyway haha.
    this is what I've done now:
    // Init
    (function(){
              destination = Folder.selectDialog('Select folder for SVG files.', docPath);
              if (!destination){return;}
              var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveArtboardIndex()];
              var ABRect = activeArtboard.artboardRect;
              // create new document with same artboard as original
              holderDoc = app.documents.add(DocumentColorSpace.RGB, new UnitValue ((Math.abs(ABRect[0]-ABRect[2])), "px"), new UnitValue ((Math.abs(ABRect[0]-ABRect[2])), "px"));
              stepThroughAndExportLayers(docRef.layers);
    in order to create the new document with the same dimensions as my orignal doc, I first read the artboardRect dimensions of the current artboard and then create the document with those values passed as parameters. the calculation is to get the real width since artboardRect gives you left,top,right,bottom values and not just height and width.
    this only works for square formats though. to make it properly you'd have to change the second "new UnitValue" to use the top and bottom values of artboardRect but I currently dont need to do so.
    * Layers to SVG - layers_export.jsx
    * @version 0.1
    * Improved PageItem selection, which fixed centering
    * @author Anton Ball
    * Exports all layers to SVG Files
    * I didn't want every layer in the SVG file so it first creates a new document
    * and one by one copies each layer to that new document while exporting it out
    * as an SVG.
    * TODO:
    * 1. More of an interface wouldn't hurt. Prefix option and progress bar of some description.
    // Variables
    var docRef = app.activeDocument,
              docPath = docRef.path,
              ignoreHidden = true,
              svgExportOptions = (function(){
                        var options = new ExportOptionsSVG();
                        options.fontSubsetting = SVGFontSubsetting.GLYPHSUSED;
                        options.embedRasterImages = true;
                        options.fontType = SVGFontType.OUTLINEFONT;
                        return options;
              destination, holderDoc;
    // Functions
    var stepThroughAndExportLayers = function(layers){
              var layer,
                        numLayers = layers.length;
              for (var i = 0; i < numLayers; i += 1){
                        layer = layers[i];
                        if (ignoreHidden && !layer.visible){continue;}
                        copyLayerTo(layer, holderDoc);
                        // Resize the artboard to the object
                        selectAll(holderDoc);
                        exportAsSVG(validateLayerName(layer.name, '-'), holderDoc);
                        // Remove everything
                        holderDoc.activeLayer.pageItems.removeAll();
              holderDoc.close(SaveOptions.DONOTSAVECHANGES);
    // Copies the layer to the doc
    copyLayerTo = function(layer, doc){
              var pageItem,
                        numPageItems = layer.pageItems.length;
              for (var i = 0; i < numPageItems; i++){
                        pageItem = layer.pageItems[i];
                        pageItem.duplicate(holderDoc.activeLayer, ElementPlacement.PLACEATEND);
    // Selects all PageItems in the doc
    selectAll = function(doc){
              var pageItems = doc.pageItems,
                        numPageItems = doc.pageItems.length;
              for (var i = 0; i < numPageItems; i += 1){
                        pageItems[i].selected = true;
    // Exports the doc to the destination saving it as name
    exportAsSVG = function(name, doc){
              var file = new File(destination + '/' + name + '.svg');
              holderDoc.exportFile(file, ExportType.SVG, svgExportOptions);
    // Makes sure the name is lowercase and no spaces
    validateLayerName = function(value, separator){
              separator = separator || '_';
              //return value.toLowerCase().replace(/\s/, separator);
              return value.replace(/\s/, separator);
    // Init
    (function(){
              destination = Folder.selectDialog('Select folder for SVG files.', docPath);
              if (!destination){return;}
              var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveArtboardIndex()];
              var ABRect = activeArtboard.artboardRect;
              // create new document with same artboard as original
              holderDoc = app.documents.add(DocumentColorSpace.RGB, new UnitValue ((Math.abs(ABRect[0]-ABRect[2])), "px"), new UnitValue ((Math.abs(ABRect[0]-ABRect[2])), "px"));
              stepThroughAndExportLayers(docRef.layers);

  • Hello. I would like to open/start a new document but I don't see the uption can you help me? thanks

    Hello,
    My name is Mimose Francois, I would like to start a new document but I can't find the option to choose either a blank or a line paper. When I click on "Open" a list of downloaded or scanned documents came up. Can you help me? thanks.

    Close Windows Media Player.
    Use Windows to locate the folder(s) in which the song files reside.  It might be "My Music."
    In iTunes, use the command File > Add Folder to LIbrary.  When the dialog comes up, point it to the folder that has the music.

  • My hard drive with library crashed, can i start on new computer with music on my touch

    my hard drive with library crashed, can i start on new computer with music on my touch

    The easiest way to get back missing items?  Restore your whole hard drive with all your irreplaceable things like photos in about 20 minutes from the backup clone you make on a regular basis.
    Your i-device was not designed for unique storage of your media. It is not a backup device and media transfer is designed for you maintaining a master copy of your media on a computer which is itself properly backed up against loss. Syncing is one way, computer to device, updating the device content to the content on the computer, not updating or restoring content on a computer. The exception is purchased content.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer - http://support.apple.com/kb/HT1848 - only media purchased from iTunes Store
    For transferring other items from an i-device to a computer you will have to use third party commercial software. Examples (check the web for others; this is not an exhaustive listing, nor do I have any idea if they are any good):
    - Senuti - http://www.fadingred.com/senuti/
    - Phoneview - http://www.ecamm.com/mac/phoneview/
    - MusicRescue - http://www.kennettnet.co.uk/products/musicrescue/ - Mac & Windows
    - Sharepod (free) - http://download.cnet.com/SharePod/3000-2141_4-10794489.html?tag=mncol;2 - Windows
    - Snowfox/iMedia - http://www.mac-videoconverter.com/imedia-transfer-mac.html - Mac & PC
    - iexplorer (free) - http://www.macroplant.com/iexplorer/ - Mac&PC
    - Yamipod (free) - http://www.yamipod.com/main/modules/downloads/ - PC, Linux, Mac [Still updated for use on newer devices? No edits to site since 2010.]
    - 2010 Post by Zevoneer: iPod media recovery options - https://discussions.apple.com/message/11624224 - this is an older post and many of the links are also for old posts, so bear this in mind when reading them.
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive - https://discussions.apple.com/docs/DOC-3141 - dates from 2008 and some outdated information now.
    Copying Content from your iPod to your Computer - The Definitive Guide - http://www.ilounge.com/index.php/articles/comments/copying-music-from-ipod-to-co mputer/ - Information about use in disk mode pertains only to older model iPods.
    Get Your Music Off of Your iPod - http://howto.wired.com/wiki/Get_Your_Music_Off_of_Your_iPod - I am not sure but this may only work with some models and not newer Touch, iPhone, or iPad.
    Additional information here https://discussions.apple.com/message/18324797

  • Start new document with view at 100%?

    Every time I start Pages a new document is zoomed at 125%. I created a template that I use all the time & set the view zoomed at 100% before I saved it.
    But every time I create new blank document (or new document from my template) it's zoomed at 125%.
    Is it possible to set it so that a new blank document, or a new one from my template starts up at 100%?

    You can set the default zoom for new documents & those opened from templates in Pages > Preferences in Pages 2 & 3. Pages 1/iWork '05 does not have this setting.

  • Setting english as the default language for a new document with arabic version of CC apps

    first off, appologies for the screen name, the name i'm sure i had registered before with account was suppose dot be looged in as was barred, so i used this in frustration.  Read the book, The Etymologicon to learn more.
    and another note.  why is the font size in the subject on this form gigantic? intentional of cockup?
    Now, to the point.
    Please please enlighten me, I'm sure it's simple but i can't find the answer and have been haphazardly ploughing the net for half the night.
    I have installed the Arabic langauge version of CC software becuase i need to do a lot of bilingual layouts.
    But
    I generally use, and start with english, but the defualt new document is always set to all the arabic settings, which is a nightmare.
    How do i make english the defualt type (and all the paragraph and language options) while retaining the functionaility of arabic version. 
    I've found instructions for CS2-6 but nothing remotely sensible about CC, and presume i'm missing something really really obvious.

    Hi,
    Here you have some interesting tutos about foreign languages in LV :
    Localizing Your LabVIEW Application to Different Languages
    Localize LabVIEW Applications in Multiple Languages
    Let me know what happens.
    Regards,
    Message Edité par Steve Mohamed le 02-27-2009 09:02 AM
    Steve M.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Vidéo-t'chats de l'été : présentations techniques et ingénieurs pour répondre à vos questions

Maybe you are looking for