Illustrator Scripting :: VBscript To Edit All Drawings In A Folder?
Mar 19, 2013
I have some +900 legacy pdf's that need to have a title and date change. The pdf's where generated in ArcMAP 10 so the text appears as individual letters. So I wrote a script that creates a knockout and adds the required text. I can get this to work for an individual file but I can't figure out is how to have the script perform it for all the pdf's in a folder.
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Open("C:WorkCity_Wide_Zoning�_Spring_2013TestA001.pdf")
' *************************
'Knockout
My script creates an artboard in my pdf file. i need to print this artboard only.
if i go to file/print manually there is an option 'Bereich' (pls see screenshot, my illustrator is in german language), so only the 2nd page is printed. (exactly what i want)
up to now i could not find this option (or something similiar) within vbscript.
code: ... appRef.ActiveDocument.Artboards.Add(Array(Rminx,Rmaxy,Rmaxx,Rminy)) ' vars are correctly set before Set jobOptionsRef = CreateObject("Illustrator.PrintJobOptions") Set printOpts = CreateObject("Illustrator.printOptions") printOpts.JobOptions = jobOptionsRef jobOptionsRef.Designation = 2 'aiAllLayers jobOptionsRef.PrintArea=2 appRef.ActiveDocument.PrintOut printOpts ....
these lines prints 2 pages: 1) main document 2) artboard
if i set jobOptionsRef.Designation = 1 only the main document is printed - but not the artboard. i need exactly the other way round, only the artboard but no main image.
in an open PDF File i press 'Ctrl+A' to select all Items in the document, then i choose Edit/Transform/rotate ... 90 degree.now i'd like to do the same with an vbscript.
the best thing i could find is:
rotate(90) Sub rotate (degree) Dim appRef, argument, element Dim changePositions, changeFillPatterns, changeFillGradients, changeStrokePattern, rotateAbout Set appRef = CreateObject("Illustrator.Application")
[code]....
not all, but all elements i am interested in are rotated - it would be better if really all elements would be rotated the elements are rotated around 'aiTransformDocumentOrigin' ... i would prefer if they are rotated around 'middle of document'.
I was wondering if there was a way to extract data from Excel to be used in Illustrator. I know there is an option of variables and xml, and I don't want that. I've seen and tried out how to read illustrator and write to excel, and I get that. What I would like to do is pretty much the opposite:
1.Pre-fill in an Excel file(.xls,.csv, doesn't matter) with data such as a filename in column 1 and (Replacement Text) in column 2 and close manually.
2. Run script(VBSCRIPT,Javascript, doesn't matter)
3.For each column in Excel file where cell in first column is not empty, open Illustrator Template with placeholder of "DWG" textframe and replace the frame titled "DWG" with Replacement text from Excel in Column2.
4, Save each to a PDF file and name file with text from Excel Column1(Filename)
In a nutshell, there will be a single illustrator template with a premade textFrame with a name of "DWG". Excel will contain two columns, one for the filename to be named and one for the relative text to replace with the placeholder in AI.
I'm using Illustrator CS 6 / ExtendScript Toolkit CS 6.
Is there any way to add arrowheads to a path with script (JavaScript or VBScript)? I don't want to make triangle or V-shaped path but add one of the built-in start and end arrowheads, scale them and set arrowhead alignment, all with script. There is no information about this topic in the Illustrator scripting references.
A client wants to modify vector drawings automatically via database, preferably Microsoft Sharepoint Server running SQL. The modifications could be as simple as changing the color of a flag or overlay or as complicated as changing object dimensions and appearance.
I'm thinking SVG, but is there a more efficient method, something that can modify Illustrator files directly?
Any way to allow a user to choose a folder from a default location. I thought I had found the solution but it's not quite working as I wanted:
#target illustrator
//Example 1 var output_folder = Folder.selectDialog ('Choose PDF output folder.');
//Example 2 var myFolder=Folder(app.activeDocument.path).selectDlg("Choose PDF output folder:");
If I use the code in example 1 the choose folder dialog appears and the 'Open' button is available and when I press the button the location is chosen as expected. However if I use the code in example 2, although the choose window opens in the path of the active documents location the 'Open' button is not able to be pressed until I select a folder., which means that the chosen location is not correct. I should indicate that I'm running this code on a Mac.
Any way to have a choose folder dialog window specify a location and be able to select that.
It is supposed to change hyphens to en-dashes in a ai files in a folder. However, when I run it, it only works on one file. After it makes the change and closes the first file, it stops.
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pdfSaveOpts; sourceFolder = Folder.selectDialog; if ( sourceFolder != null ) { files = new Array(); fileType = "*.ai"; files = sourceFolder.getFiles( fileType ); if ( files.length > 0 ) [code]....
I'm using Illustrator for work and I love it, I never needed scripts yet. Now I have couple houndred svgs coming in per day, I would like to have a script that opens every svg one by one in the selected directory and add them to a pdf as pages of the same size and than save it.
How do I set a folder as a relative path to where the script is running?
is there any easy way like in unix, starting without / ?or for example
"~/Desktop/"
"/users/<login>/desktop/"
seems that path to me is the only way...
is there an easy way to change posix paths to applescript??
I have this code:
tell application "Finder" to set templateFile to (container of (path to me) as string) & "Graficas FINAL ADQAT.ai"
with this error: error "No se ha encontrado el archivo Macintosh HD:Users:Vibra:Desktop:Graficas FINAL ADQAT.ai." number -43 from "Macintosh HD:Users:Vibra:Desktop:Graficas FINAL ADQAT.ai"
the file is there how I change the filepath to be compatible with applescript?
I'm trying to use some images in my ScriptUI dialog, but I want to use a "relative" path name, and I can't seem to get it to work.For example, this myScript.jsx works just fine, but as you can see, I'm using an "absolute" path name to transparencyGrid.jpg:
var w = new Window ("dialog"); var f = new File ('~/Desktop/transparencyGrid.jpg'); w.add ("image", undefined, f); w.show ();
However, I want to be able to use a relative (to myScript.jsx) path to point at transparencyGrid.jpg, like this:
var w = new Window ("dialog"); var f = new File ('../../../transparencyGrid.jpg'); w.add ("image", undefined, f); w.show ();
But, I can't seem to get this to work because relative paths seem to be relative to the current folder, Folder.current, not the location of the currently executing script.I say that because when I do this:
alert(Folder.current);
The only thing the alert message shows is a backslash (/), indicating to me that the current folder is the root of my OS, but I thought it would be the folder where myScript.jsx resides.
So, is there a way of setting Folder.current to the location of the actual script?
I created an Action to batch export a folder of .ai files to create 300dpi .png's of the .ai file's artboard. I did this by simply recording "Export...as png" with my desired settings then Batch running the Action on desired folder of .ai files. The files were successfully exported, the trouble is that the exported files lack a .png file extension. My intent is to take these PNG files and merge them into a single PDF using Acrobat Pro. Unfortunatly, without the .PNG extension, Acrobat Pro does not recognize the file types and does not let me use the Combine Files feature on them. Going back and manually adding a .png at the end of the exported files defeats the time-saving purpose of Batch Processing all together. Is there something I am missing or doing incorrectly? I have included screenshots of 1) My Batch Action settings 2) folders showing files without .png extension and 3) visual of what I see when I am trying to combine PNGs into a PDF.
I recently found the following jsx script, which saves a multi-layered IL file into 1-layer-per-file with PNG format.
This file is very useful, but i'm currently working on a project that requires the files to be saved into SVG format.
Is there anyway to edit this script to save the files as SVG instead of PNG?
// *** Export Layers as PNG files (in multiple resolutions) *** // // Version: 1.0 (29 Aug 2012) // Copyright Arcticmill 2012 // www.arcticmill.com // Developed by: Johan Otterud // // This script will export all layers that have a name starting with "#", or "%" into a subfolder of the current .ai document. // These options can be configured below: // *** Config options *** var subFolderName = "Export";
[Code]...
Remember that you must add a "" + exportLayersStartingWith + "" (when exporting the layer cropped to it's bound) or "" + exportLayersWithArtboardClippingStartingWith + "" (when layer should be clipped to artboard) to the beginning of the layer name. Also make sure that they layers you want to export are not locked or hidden.");
} else { // Show a completed message alert(layersToExportCount + " layer(s) was successfully exported to: " + exportDirectoryPath); }
I'm try to automate the importing of the Varaible and datasets into my graphs via Scripting, but the ImportVaraibles() function doesn't seem to work. Here is my Script, mostly copied from the example script provided with Illustrator (CS5). And, this works manually, using the file names in the script, via Load Variable Library
Set appRef = CreateObject(strIllistratorVersion)
'Open the file and import the datasets Set docRef = appRef.Open(strTemplate & "200-500.ai") 'docRef.Datasets.RemoveAll docRef.Variables("Yearbook").Delete
Here is the problem, after I delete the previous library, then this next line, right from the example, does nothing The script then exits with 'No Datasets in this document'
docRef.ImportVariables (strXMLFolder & "Lumber_200-500.xml") 'appRef.DoJavaScript "alert('Template:" & strTemplate & strRange & ".ai | XML file:" & strXMLFolder & "" & objFile.Name & "^')" If (appRef.Documents.Count > 0) Then Set docRef = appRef.Documents(1)
[Code]....
If I remove that delete line, the script runs, but just uses whatever Variables I had last loaded, not the XML file.
It's simply not loading. What do I need to do to get it to load?
this morning to find all of the drawings in one folder are giving this error message when i try to open them? Error 0x0000 e651d9d4h. all was fine yesterday when they were closed however today they are not working. I have tried to recover them and although the process comes back as resolved as the drawings tries to open it returns the same message?
We are copying our original files to a sub folder to make revisions that have only happened after bidding. We want to keep our original bid documents intact. I have created a sub folder called 'Confirmed Documents' and added Constructs, Sheets, Elements, etc.
I copied the files over and used the Reference Manager to repath the files. However, all of my schedules and room tags now use the 'NA' prefix because it is not reading the project information. How can i reconnect this folder to the project folder?
We are copying our original files to a sub folder to make revisions that have only happened after bidding. We want to keep our original bid documents intact. I have created a sub folder called 'Conformed Documents' and added Constructs, Sheets, Elements, ect.
I copied the files over and used the Reference Manager to repath the files. However, all of my schedules and room tags now use the 'NA' prefix because it is not reading the project information. How can i reconnect this folder to the project folder?
I was wanting to create a script to go through and clean up a bunch of drawings in a given folder. I've written a lisp routine (cleanx) that works fine when you run it on a single drawing, but I'm having some trouble integrating it into a script. As it is currently, I'm experiencing several issues -
1) It prompts the user for an 'object' after finding 0 objects. It seems to be caused by the line,
(command "-layer" "u" "*" "t" "*" "on" "*" "" "")
in 'cleanx' based on the text window, but I'm not sure why it does that given that if I run cleanx directly it doesn't prompt me.
2) It ends with saying 'Really want to discard all changes to drawing?' which confused me as I use Qsave before I close, and then confused me further when I realized that the text window suggests that this prompt comes up after the 'open' command, and that if I type <Y> (exit without saving) then it asks me to select a file. Why doesn't it save, close and then open the next file automatically?
I am running AutoCad LT 2005 and have had no problems copying and pasting drawings into Word, and then double clicking to edit them if needed in AutoCad.
I have recently had DWG TrueView 2011 installed on my machine and it has taken over the associations with CAD drawings in a Word document, so that I cannot edit them.
how to change the associations back to AutoCad LT for CAD drawings in MS Word ?
We have a customer that sends us drawings with Arabic fonts that we sometimes need to edit and insert Arabic fonts. Is this possible in the English version of AutoCAD? If so, how do we go about loading Arabic fonts?
The 2D drawings I am working with were exported from 3D REVIT files to 2D AutoCAD files. There are several XREFed drawings that are both mechanical and architectural from the original REVIT files that for whatever reason, the block's line weights came over with line weights of 70 in those blocks.
When I plot, the objects are a blur with the line weight so high. I tried using the command "setbylayer" but that didn't work since nested blocks still had lineweights of 70. Is there a VBA or LISP routine to run through all the blocks (including nested) that can change the line weights to a given number?
I need to be able to batch process a bunch of title block attributes automatically.
Block Name: Title Block
Tag Name: SH
Currently they come out with just the number 1, 2 , 3 etc I need to add a leading zero ie 01, 02, 03 etc
All the scripts I have will just replace the number with another
I just want to append the zero infront of the existing number
ie the code will need to read the existing number and decide if its less than 10. if it is less than 10, then the code just needs to append the leading 0. if its 10 or over, then do nothing.
I have Windows XP, last night i moved all JPEG Images in my computer and when i opened it back up I noticed that my JPEG images are no JPEGS!!! I can't open my picture any more??? I check their properties and they are now VBSCRIPT files?? I want them back to JPEGS so I can view them.
I just noticed that some of my photos are missing from the library in lightroom, specifically the original versions of photos that have virtual copies edited in photoshop in folders that have since been synchronized. Weird, and very anoying. The files are still there (in wondows explorer) but when I try to re-import them lightroom doesn't see them, only the PS edited copies (.tif files). I told lightroom to allow duplicates and it sees all the photos in the folder except those missing ones. This does not happen to my PS edited virtual copies in folders that have not been synchronized. It is not a matter of stacking, or at least Lightroom does not think the PS copies are stacked at all so I can't unstack them. How to get them back into lightroom (preferably with the accompanying development settings) and also how to avoid this problem in the future.
PS: I import files from my camcorder using a different program because lightroom does not acknowledge that particular video file format. That's why I have to synchronize some folders and not others.