Copy to new artboard with transformation in VBA

Hallo Forum,
I have the common problem to resize the artboard to standardize technical illustrations to the format 50x50mm. So I found good help in the forum (thank you). I have some problem and may somebody can help me:
I would like to group the objects for further transformations
I would transform the group to 45mm and scale stroks and effects
N.B.: here It should be a test on landscape format
I would align the group to the page center
This is my code, may somebody can help me ?
Thank you to every replay
Regards Alex
Public Sub copy_paste_with_transformation ()
'Duplicates grouped items in a new document with landscape sensitive transformation
Set appRef = CreateObject("Illustrator.Application")
'calculate the size of objects do define if it's landscape or not
Bounds = appRef.ActiveDocument.VisibleBounds
'If the group is landscape the lenth should be 45mm otherwise the higth
appRef.ActiveDocument.GroupItems 'problem
appRef.ActiveDocument.SelectObjectsOnActiveArtboard 'may a solution for CS4 too
appRef.ActiveDocument.Resize(45, 45) 'problem
appRef.ActiveDocument.copy
Set newDocument = appRef.Documents.Add(aiDocumentCMYKColor, 50, 50) 'Paper size is 50mm
newDocument.Paste
'Align group to page center hrizontal and vertical
End Sub

Not in VB ( klingon ) but ExtendScript… May be you can look this up and translate?
#target illustrator
newDocGroup();
function newDocGroup() {
          var mm = 2.83464567, grpFile, doc, scale;
          grpFile = File( Folder.desktop + '/Testing.ai' );
          doc = app.documents.add( DocumentColorSpace.CMYK, 50*mm, 50*mm );
          doc.groupItems.createFromFile( grpFile );
          if ( doc.pageItems[0].width >= doc.pageItems[0].height ) {
                    scale = ( 45*mm / doc.pageItems[0].width ) * 100;
          } else {
                    scale = ( 45*mm / doc.pageItems[0].height ) * 100;
          doc.pageItems[0].resize( scale, scale, true, true, true, true, scale, Transformation.CENTER );

Similar Messages

  • 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);

  • I can't get download to work - it will not copy the mp3 file to my chosen location (as set in tools/options) - it gives me a new window with a player - no dwnlo

    I am running windows xp sp2 and I have set my dowload location under (tools/options), but when I select an MP3 file to download, firefox does NOT copy the file to my chosen location on my HD - instead, it opens up a new window with a makeshift "player" and begins loading the player with the MP3 file. The problem is that I have no idea where on my system firefox has copied this file to, so, I cannot leave and come back later and play this MP3 file using winamp. I have to listen to it right then or lose it - if I close that new window (with that puny little "player"), then I lose the download, wherever firefox put it on my PC (I got no idea where it is). This is all under firefox 25.0
    I am also running FIrefox 12.0 on an older windows 2000 machine and that works perfectly - I can download any MP3 file I want, and firefox 12.0 (on win2k, sp4) downloads it to my chosen location (on my HD), and it gives me the download window so I can watch its progress and have some control over pause, and resume, and, when it is done, the download window offers me the option to "open containing folder" so I can make sure it got to where I wanted it. In other words, Firefox 12.0 on WIn2k, sp4 works better than firefox 25.0 on winxp sp2!!!!! What gives? I went through and set up my options for XP just like I did with Win2k and it all looks good, but firefox 25.0 just ignores my chosen location and always defaults to give me that makeshift player and I am not able to actually copy the mp3 file to my harddrive - it makes firerox 25.0 almost unusable since downloading mp3 files is a big part of my firexfox use - please help - I am not able to upgrade windows at this time, and, since firefox 12.0 still works fine on win2k, I can't understand what happened at firefox?

    Phillipp,
    I tried it again using "save link as", and this time it actually worked! I just now downloaded several more using the "save link as" option, and it works perfectly. Thanks. Problem solved.
    Littleberry

  • How can I copy my iTunes library with playcount information to a new computer?!?

    Hello,
    I'm about to get a new computer. I have all my music on a external HD, so I won't have problems preserving my music. But I would like to preserve other information too. Especially the play count information. I think it's interesting how my top 25-most-played looks like, and the play count list I have now, took me 2 years to get.
    So my question is: Does anyone know how I can copy my iTunes library with all its information (play count, rating, comments, images, last played date etc.) to a new computer?
    Thanks a lot!

    Connect the external HDD to the iMac, launch iTunes while holding down the Option key. Choose the option to select library and navigate to the top level folder of the iTunes media on the external. Select it and click OK.

  • I installed lion from the internet, i wanted all the stuff on it erased but it didnt do it, how do i get my computer to factory settings so it is like it was new just with a fresh copy of lion on it

    i installed lion from the internet, i wanted all the stuff on it erased but it didnt do it, how do i get my computer to factory settings so it is like it was new just with a fresh copy of lion on it

    Music is not included in the backup (and nor are films or tv shows), only the contents of third-party apps are included. Did you not do File > Transfer Purchases when connected to your computer's iTunes to copy your iTunes purchases over, and/or have you not got a backup copy of your music somewhere e.g. on an external drive ?

  • How to copy paste a new page with thumbnails view in Pages 5?

    How to copy paste a new page with thumbnails view in Pages 5?

    Feature removed along with over 90 others:
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=b14426a2c5af2 65f2213d98ee45f08d7&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Export your Pages 5 files to Pages '09 or Word .docx and trash/archive Pages 5.
    Then rate/review Pages 5 in the App Store.
    Peter

  • How to copy a generic extractor with function module into a new system?

    Dear Gurus,
    i would like to know how i can copy a gneric datasource with function module from one system to the target system.
    Thank you
    Cheers

    Hi Anesh,
    thank you for replying.
    Since the Datasource will have a new new in the new system, i will create a new one.
    Create a generic datasource base on the table is not the problem.
    My problem is how could i copy the FM in the new system?
    If you can help me on that, it will be fine.
    Thanks

  • How to copy my bookmarks in a PC with WindowXP to a new PC with Windows 7

    I have hundred of bookmarks in an old PC with windows XP operating system. I would like to copy all these bookmarks in a fast way and put them in a new PC with Window7.

    The bookmarkbackups folder contains .json files which can be used to restore -- completely replace bookmark on your new system with the old bookmarks. But I think you would be better off by bringing over your entire Firefox profile.
    * https://support.mozilla.com/en-US/questions/895863

  • Just got my Mac air and i would like to make a file to store some web addresses for my new business with rodan and fields and I can't do it. Made the file but i cant copy and paste the web addresses in the file to save them. Please help and thank you.

    Just got my Mac air and i would like to make a file to store some web addresses for my new business with rodan and fields and I can't do it. Made the file but i cant copy and paste the web addresses in the file to save them. Please help and thank you.

    Yes - well you have to make the file in a word processing Application.
    You could use TextEdit (it's free) Pages (words only), or Numbers (data base) (they are part of iWorks - and may or may not be free (included) on your machine.  You could use MS Office (it is not free) You could use any Open source word processor that plays well with Office (NeoOffice, StarOffice) they are free.
    That's how you create content and copy/paste URLS. Then you save the file to the desktop. If you are going to make more than one file... you make a folder on the desktop and save, or drag the file(s) into it.
    You attach it to your e-mail client which will compress it and e-mail it. An excellent reference is to use Help, from the menu bar, also from inside any application. From your library or book store the OS X for Dummies has a lot of useful information (you don't read it cover to cover but look up chapters about what you'd like to do)
    You can also make appointments at your local Apple store for individualized help (if a store is nearby)

  • I cannot install my copy of Photoshop elements on my new PC with windows 8, it wasOK with Windows7

    I cannot install my copy of Photoshop elements on my new PC with windows 8, it was OK with Windows 7.
    Can I get an update for this?
    BizRit

    The workaround for this problem is to revert to IE9 or earlier, install your old PSE, then reinstall the latest IE version.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.

    Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.
    when you copy n paste into a new table, all the cell sizes are changed.
    is there a way to put in a new table from your templates into an existing file, different to the standard very basic ones in insert table.
    I look forward to your answers.  Your help is very much appreciated.
    Also how do you search for question answers already written in this support area please.

    Hi Jason,
    In Numbers 3, you can select a whole table by clicking once in the table to make it active, then click once on the "bull's eye" at the top left.
    Now copy and paste. All formatting (and any cell content) is pasted intact. In Numbers 2.3 (Numbers '09) it is a little different for selecting a whole table. But I won't go into that unless you are using Numbers '09. Please reply.
    I don't like the look of the tables in Insert Table. I keep custom tables in My Templates. I have set Numbers > Preferences > General > For New Documents > Use template: (name of my favourite custom template)
    That opens when I launch Numbers, or ask for a new document (command n). Note that if you follow this preference setting, then Menu > File > New From Template Chooser (for another template) requires you to hold down the option key in that menu.
    Regards,
    Ian.
    Message was edited by: Yellowbox. All formatting (and any cell content) is pasted intact.

  • Wrong sequence settings used on my timeline; can I copy the timeline to a new sequence with correct settings?

    The clip properties are Frame size 1440x1080, 23.98 fps (yes a problem for FCE), Compressor:  Apple Intermediate Codec, but unfortunately I did all of my hard work on a 30 minute film on a sequence that has SD settings (Frame size 720x480), 29.97 fps, compressor: DV/DVCPRO- NTSC. I first noticed there was a problem when I could only get the exported quicktime movie to appear as a 4:3 when it was supposed to be a 16:9.  I have overcome that problem by exporting using quicktime conversion and customizing the settings to reflect the correct item properties of the original clips. 
    But my concern is that my project is still fundamentally based on a timeline that was created in a sequence with SD settings and that maybe I have lost some resolution quality.  I am sitting here looking at the iDVD preview and I am not always sure it looks as sharp as the same clip viewed in FCE dropped in a sequence with the right settings.  But maybe iDVD preview isn't as sharp, or maybe it's just myimagination.  Any thoughts?
    Ideally, what I would liketo do is to copy my timeline out of the first sequence with the wrong settings,and to copy it into a new sequence with the proper settings.  But I am wondering if that timeline is now "infected" with the wrong settings,and brings these over to the new sequence.  The guy on the Apple help linetold me this was unfortunately the case.  Am I really going to have tocompletely do this work over again to get a completely correct workflow?
    Any way around this?

    Al,
    very much appreciate your time on this.  Hopefully just one more question.  I am trying to figure out whether or not converting the tremendous amount of footage I have from this project shot in 24p will be worth it.  In my mind, it is only worth it, if by not doing it, I will end up with a finished product that does not have as good of a picture quality.  At this point, I dont care at all about having the 'film look' 24p is supposed to give you, I just dont the picture quality degraded somehow because FCE doesnt support 24p, and I am using a 29.97fps sequence to edit it. 
    So with all of that said, my question is this:
    1.  When you said before that when a clip hits a sequence it conforms to the properties of the sequence, what do you think is happening to the clip?  For instance, if the clip in the Browser as you shot it has got 1440 pixels for every 1080 lines and you place it on a 720x480 sequence, is some of that information literally disappearing?  That seems hard to believe.  I would think that kind of conversion would require a program to execute it and some processing time, but the drag and drop on a sequence is instantaneous.  And my HD footage on the SD sequence still seems to look better to me than my SD stuff, although that could just be perception.  Same issue with the frame rate.  When I drag and drop a 24fps clip onto a sequence set for 29.97 fps, how can the clip now have more frames per second?  That would be additonal information that was never captured in the first place.  How is that possible?  I do believe that the clips are changed in some way that affects the output, but it doesnt seem possible that 'conforming' to the properties of the sequence is the same thing as if you shot the original footage with those sequence settings. Something else must be meant by that right?
    2.  Will converting the original clips in streamclip change the frame rate..them from 24p to 29.97?  If they are still 24p, then don't you still run into the same problem when you edit in FCE?  And if they are changed to 29.97, how is that better than just dropping them onto a sequence set to HDV 1080 29.97fps and having it conform to that?  What exactly is the upshot of doing the streamclip conversion?  Especially if I don't care about the 24p look now.

  • HT2486 how do I copy an existing Group in Contacts to create a new group with the same contacts in it?

    How do I copy an existing group in Contacts to create a new group with the same contacts in it?

    Hi there,
    Unfortunately the use case you describe hasn't been implemented in Firefox. It's not possible to move a tab group out to its own window at this point. Generally the tab groups feature hasn't been worked on much recently, not sure why.
    As to TabMixPlus, that's a third-party add-on which Mozilla doesn't directly support. You can find support links from the add-on page: https://addons.mozilla.org/en-us/firefox/addon/tab-mix-plus/
    Hope this helps.
    Cheers,
    David

  • Any news to the copy and paste problem with osx 10.9 ms rdc client?

    we have a new macmini with 10.9 and we work with microsoft remote desktop client 8.0.5,
    since we use this combination, we can´t copy and paste text between both systems...
    regards
    shift_f7

    Hi,
    Yes, it is not supported in the current versions.
    The workaround is to use folder redirection.
    Folder redirection enables access local folders during the remote session. Click the + button at the bottom of the dialog and choose a folder you want to have redirected.
    Configure Folder Redirection
    1. Click the + button.
    2. In the Add Local Folder window, enter the following information:
    • Name: Set a name for the folder to be available during the remote session.
    • Path: Select the path to the folder to be available during the remote session.
    3. Click the exit button to save the remote desktop.
    Thanks.
    Jeremy Wu
    TechNet Community Support

  • I have a legit copy of 4.3 on an old unit. Can it be burned on a dvd and installed on new PC with windows 8.1?

    I have a legit copy of 4.3 on an old unit. Can it be burned on a dvd and installed on new PC with windows 8.1?

    Yes, one you have your LR 4 user license. (if it was an upgrade from an earlier version then you will also need the earlier version license key.)
    You can get the latest update for LR 4 from the link below, and install that instead of the 4.3 version.
    http://www.adobe.com/support/downloads/product.jsp?product=113&platform=Windows

Maybe you are looking for

  • Long running query--- included steps given by Randolf

    Hi, I have done my best to follow Randolf instruction word-by-word and hope to get solution for my problem soon. Sometime back I have posted a thread on this problem then got busy with other stuff and was not able to follow it. Here I am again with s

  • Need help in oracle data recovery

    Friends ,i need help in oracle data recovery. I had an oracle 8i database running on windows. For some reason Windows operating system crashed. It is not booting up. I dont have current backups.But my database physical files are in the disk. Controlf

  • Type mismatch errors in 10g

    I have migrated an 8i database to 10g 10.2.0.3. I am getting a compile error on a procedure which is now INVALID referencing a package which compiles ok and is VALID. The compile error I get on the procedure is: PLS-00386: type mismatch found at 'PIO

  • Can't find KINBC8A.SAR file for PI_BASIS 2006_1_640

    Hello, I'm trying to upgrade to PI_BASIS 2006.1.640. As per note 1007796 I need to unpack archive KINBC8A.SAR but the file is not available for downloading with 51032427.zip file from the SAP Software Distribution Service. Do you know where can I get

  • Macbook Pro case buzzing

    There is an intermittent buzzing on the right side of my macbook pro keyboard (near the right speaker grill). As far as I can tell it is independant of the display, cpu usage or temperature. I think it's a problem with the case because it goes away i