Draw a pen path, then a script to select/copy and close activeDocument

Is this possible?
I do this step 90 times every day:
Select a image area drawing a pen path zone, and copying it to the clipboard.
Then close without save.
Then I use the selection on clipboard to paste it on the previous opened image.
P.S. I use paths because I need to have a more accurate and precise curves.

Does this help?
// get active path, close document without saving, create path;
// 2011, use it at your own risk;
#target photoshop
if (app.documents.length > 1) {
// identify path;
var thePath = selectedPath();
if (thePath != undefined) {
var myDocument = app.activeDocument;
// set to pixels;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// collect info;
var thePathInfo = collectPathInfoFromDesc(myDocument, thePath);
// close withpout saving;
myDocument.close(SaveOptions.DONOTSAVECHANGES);
// create path;
createPath(thePathInfo, dateString());
// reset;
app.preferences.rulerUnits = originalRulerUnits;
else {alert ("no path selected")}
////// determine selected path //////
function selectedPath () {
try {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var theName = desc.getString(charIDToTypeID("PthN"));
return app.activeDocument.pathItems.getByName(theName)
catch (e) {
return undefined
////// collect path infor from actiondescriptor //////
function collectPathInfoFromDesc (myDocument, thePath) {
//var myDocument = app.activeDocument;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// based of functions from xbytor’s stdlib;
var ref = new ActionReference();
for (var l = 0; l < myDocument.pathItems.length; l++) {
     var thisPath = myDocument.pathItems[l];
     if (thisPath == thePath && thisPath.name == "Work Path") {
          ref.putProperty(cTID("Path"), cTID("WrPt"));
     if (thisPath == thePath && thisPath.name != "Work Path" && thisPath.kind != PathKind.VECTORMASK) {
          ref.putIndex(cTID("Path"), l + 1);
     if (thisPath == thePath && thisPath.kind == PathKind.VECTORMASK) {
        var idPath = charIDToTypeID( "Path" );
        var idPath = charIDToTypeID( "Path" );
        var idvectorMask = stringIDToTypeID( "vectorMask" );
        ref.putEnumerated( idPath, idPath, idvectorMask );
var desc = app.executeActionGet(ref);
var pname = desc.getString(cTID('PthN'));
// create new array;
var theArray = new Array;
var pathComponents = desc.getObjectValue(cTID("PthC")).getList(sTID('pathComponents'));
// for subpathitems;
for (var m = 0; m < pathComponents.count; m++) {
     var listKey = pathComponents.getObjectValue(m).getList(sTID("subpathListKey"));
     var operation = thePath.subPathItems[m].operation;
// for subpathitem’s count;
     for (var n = 0; n < listKey.count; n++) {
          theArray.push(new Array);
          var points = listKey.getObjectValue(n).getList(sTID('points'));
          try {var closed = listKey.getObjectValue(n).getBoolean(sTID("closedSubpath"))}
          catch (e) {var closed = false};
// for subpathitem’s segment’s number of points;
          for (var o = 0; o < points.count; o++) {
               var anchorObj = points.getObjectValue(o).getObjectValue(sTID("anchor"));
               var anchor = [anchorObj.getUnitDoubleValue(sTID('horizontal')), anchorObj.getUnitDoubleValue(sTID('vertical'))];
               var thisPoint = [anchor];
               try {
                    var left = points.getObjectValue(o).getObjectValue(cTID("Fwd "));
                    var leftDirection = [left.getUnitDoubleValue(sTID('horizontal')), left.getUnitDoubleValue(sTID('vertical'))];
                    thisPoint.push(leftDirection)
               catch (e) {
                    thisPoint.push(anchor)
               try {
                    var right = points.getObjectValue(o).getObjectValue(cTID("Bwd "));
                    var rightDirection = [right.getUnitDoubleValue(sTID('horizontal')), right.getUnitDoubleValue(sTID('vertical'))]
                    thisPoint.push(rightDirection)
               catch (e) {
                    thisPoint.push(anchor)
               theArray[theArray.length - 1].push(thisPoint);
          theArray[theArray.length - 1].push(closed);
          theArray[theArray.length - 1].push(operation);
// by xbytor, thanks to him;
function cTID (s) { return cTID[s] || cTID[s] = app.charIDToTypeID(s); };
function sTID (s) { return sTID[s] || sTID[s] = app.stringIDToTypeID(s); };
// reset;
app.preferences.rulerUnits = originalRulerUnits;
return theArray;
////// function to create path from array with one array per point that holds anchor, leftdirection, etc, 2010 //////
function createPath (theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
lineSubPathArray = new Array ();
if (theArray[theArray.length - 1].constructor != Array) {var numberOfSubPathItems = theArray.length - 1}
else {var numberOfSubPathItems = theArray.length};
for (var b = 0; b < numberOfSubPathItems; b++) {
     var lineArray = new Array ();
     for (c = 0; c < (theArray[b].length - 2); c++) {
          lineArray[c] = new PathPointInfo;
          if (!theArray[b][c][3]) {lineArray[c].kind = PointKind.CORNERPOINT}
          else {lineArray[c].kind = theArray[b][c][3]};
          lineArray[c].anchor = theArray[b][c][0];
          if (!theArray[b][c][1]) {lineArray[c].leftDirection = theArray[b][c][0]}
          else {lineArray[c].leftDirection = theArray[b][c][1]};
          if (!theArray[b][c][2]) {lineArray[c].rightDirection = theArray[b][c][0]}
          else {lineArray[c].rightDirection = theArray[b][c][2]};     
     lineSubPathArray[b] = new SubPathInfo();
     lineSubPathArray[b].closed = theArray[b][theArray[b].length - 2];
     lineSubPathArray[b].operation = theArray[b][theArray[b].length - 1];
     lineSubPathArray[b].entireSubPath = lineArray;
var myPathItem = app.activeDocument.pathItems.add(thePathsName, lineSubPathArray);
app.preferences.rulerUnits = originalRulerUnits;
return myPathItem
////// function to get the date //////
function dateString () {
     var now = new Date();
     var day = now.getDate();
     day = bufferNumberWithZeros(day, 2);
     var month = now.getMonth();
     month++;
     month = bufferNumberWithZeros(month, 2);
     var year = now.getFullYear();
     var hour = now.getHours();
     hour = bufferNumberWithZeros(hour, 2);
     var minutes = now.getMinutes();
     minutes = bufferNumberWithZeros(minutes, 2);
     var seconds = now.getSeconds();
     seconds = bufferNumberWithZeros(seconds, 2);
     var myDateText = year+"-"+month+"-"+day+"_"+hour+"-"+minutes+"-"+seconds;
     return myDateText
////// buffer number with zeros //////
function bufferNumberWithZeros (number, places) {
     var theNumberString = String(number);
     for (var o = 0; o < (places - String(number).length); o++) {
          theNumberString = String("0" + theNumberString)
     return theNumberString

Similar Messages

  • When i go to my game center app i login and it says i have to creat a profile and i hit yes then i bowunce inbetween selecting country and birth date what am i doing wrong

    when i go to use my game center app i login and it tells me i have to creat a profile so i hit yes and then i bownce inbetween selecting country and selecting birth date what am i doing wrong???????????????
                                                                                                                        -Acedog

    what am i doing wrong???????????????
    You were perhaps born in the wrong place on the wrong day!

  • Drawing tools (pen, pencil, brush) wont keep style selection.

    I can not seem to have any of the drawing tool (pen, pencil or brush) keep the stlye selection I assign to it.  I have to KEEP going back to the line I just drew selcet is and assign the stlye to it once again.  This makes for a VERY SLOW process/drawing.  Any ideas where I can adjust the settings so that the style STAYS on the tool when drawing?
    Many thanks!

    Go to the Appearance Panel and from the flyout menu uncheck New Art Has Basic Appearance and that should solve your problem. If in the future you need this not to work this way rememeber to check it again.

  • How do I copy and paste an image form the internet to Keynote. I have done this successfully in the past by selecting copy and then paste by using the right click function and now am unable to do so. I am thinking it is an outdate OS problem...not sure.

    How do I copy and paste an image from the internet to Keynote. I have done so successfully in the paste by using the copy and paste right click functions but am unable to do so now. That was about a year ago that I attempted that I was able to do this. Thank you for your help.

    Some images are copy-protected.
    If all else fails, you can make a screen shot of the image: 
    With the image visible in your browser, press CMD-Shift-4 and your cursor will change to crosshairs.
    Position the cross hairs at one of the corners of what you want to copy and drag to the opposite corner, then release the mouse. An copy of the image will be saved to your desktop.
    You can now edit and use this image.
    Be sure to respect copyrights.
    Message was edited by: bwfromspring hill

  • Don't know how or where to create user.js file so I can add script to allow copy and paste into a webbased email

    I am trying to compose an email from the email address on my web page. The email editor program (or Mozilla) doesn't allow me to do that. The instructions that Mozilla provided said to find the user.js file in Firefox's profile directory. I can't find such a file. I don't know where or how to create this file or how to write into it the lines that the instructions provided. I also don't know what url I am supposed to substitute for mozila.org that is in the lines of script.

    This was helpful. Now, to to do what I need to do I have to add something to the user.js file as per directions regarding ''setting prefs for Mozilla Rich Text Editing Demo'' to allow a copy and paste. It instructs me to change the URL from mozila.org to where I want to enable the function. I am not sure what that means. I am trying to to do something in the "back office" of my web site. I want to send an email from the web site's email. I am trying to copy and paste a pdf file into the body of the email but was not able to do it. I was directed to the setting prefs page. Do I change the location to the URL of my web site or the web site of the web host?

  • Fixing paths after drawing with pen tool?

    Afer you draw a shape with the pen tool and you are not happy with the way you drag the curves and drew the path, do you do anything more with the pen tool at that point or do you later fix it with the Direct Selection tool to manipulate the anchor points to fix it?
    Thanks.

    Access to the direct selection tool works only when you clicked on it before choosing the pen tool
    If you select the direct select tool before you choose the pen tool it will be accessible by holding the command/control key but if you have the selection tool selected first and then of course it shows up you can in CS 4 and 5 also then hold the command/option Tab key to toggle the direct select and selection tools while still in the pen tool.

  • Create smooth selections in PS from PAPER drawings ,convert to "smooth paths" then paste to AI

    *******Enhancement / FMR*********
    Brief title for your desired feature:
    selections converted to paths in PS, or AI.
    How would you like the feature to work?
    If you draw with hard edged brush or pen in PS and paste to AI , the trace tool in Ai works very well, for swirls, cartooning, hand drawn perspective illustrations etc,
    but if you draw on paper and take a photo, which I do with a camera connected to the pc because it saves a small file size jpeg automatically into bridge, 250kb average,
    and open it in PS, to do a magic wand selection of the lines, then refine edge to smooth and tighten it up. It looks great at this point,
    Then paste this selection of pixels to Ai for tracing to get crisp vector edges from the selected pixel outline,
    or convert the selection to paths first, then paste the paths into Ai,
    in both scenarios the resulting trace outline has many jaggy edges, even if pasted into PS as paths, since the paths created in PS from the smoothly made selection still capture any diagonal pixelated edge even if the image is 300ppi and results in showing all the jaggies.
    I have tried all the trace settings and variables in AI, from simple through to photoreal.Even if you expand these traced results and use the pathfinder shapemode / unite it still creates crinkle edges. Which results in an hour plus of work redrawing the whole thing.might aswell just use the pen tool to start with.
    Trying to use the path/simplify tool is not useful as it smooths out all your shapes and changes the contours of the path too much regardless of angle threshold or curve precision, and the smooth function on the pencil tool changes the paths too much too when trying to smooth out the "jaggies" lines.
    I`ve tried creating a "shape" out of the path in PS but its also jaggy as it just replicates the path already made.
    tracing with the freeform pen tool in ps is faster than pen but creates uncontrolled edges.
    ** I was hoping there could be a setting to convert the selection to a vector path minus the jaggies or crinkles that occur on round or diagonal parts of the selection.
    Why is this feature important to you?
    allows me to freehand sketch on paper, create a selection in PS, convert to path, and paste that vector path into AI , problem is its a jaggy path,
    image below is selection in PS
    Convert to paths in PS, captures all the jaggies and crinkles,
    this sample is hand drawn,
    I smoothed and tightened the edges in "refine edge" in PS below. It looks to create a nice contour,
    however converting to paths gets in very close and still picks up jaggies, due to the pixel build of imagery.
    the result after refine edge dialogue below, I fill with green to copy paste this selection to AI, could also have pasted the channel but chose this, does same result anyway
    in Ai below, regardless of trace type, it produces either uneven edges that dont match the pixel contours or if I make a 6 or 16 colour trace or photoreal it creates many jaggied bumpy edges, as I said earlier if I unite it all with path finder I still have to redo all the contours with pencil, the path/simplify command ruins the outlines shapes and corner points. MIght as well just start with pen tool in this case, the long but sure route.
    However I`m hoping Adobe can create a formula for this purpose, to get that smooth selection to be a smooth path instead of jaggy bumpy. not sure if I`m making any sense here... is this understood?

    the formula could be written to connect the inside corners of the selection steps with a smooth vector line on concave turns (if your viewing the selection from outside the shape, like a "dip" or valley,  and the  vector line would change to connect the outside of each step corner on convex turns (mounds or lumps, "hills") viewed from outside the selected shape. Then this result smoothed to create smooth transition for the vector line.
    Like a very tight fit smooth moving average on a stock chart, but perfectly fit to the data as there is no time lag. perhaps look at wavelets, but respecting mitres, I`m not a maths person or programmer but have seen some things that made me consider these,
    anyway this tool would speed up my work in PS and AI if possible,,thanks,,

  • Pen Path not visible - Illustrator CS4

    Hello all,
    I am a relatively comfortable user of Illustrator - but just now I have encountered a problem whereby my pen path tool is not visible as I draw. When objects are selected with either the selection tool or direct selection tool the path outline is not made available to select. All I get is a generic bounding box with the selection tool - with the direct selection tool I get nothing.
    I have scoured the user preferences for some hidden setting - all I can think is that I've mashed the keypad in some wierd and wonderful way that has made this suddenly happen.
    Any pointers or help would be much appreciated.

    Thank you, that sorts it! In all my years I have never needed that function - I did not know it existed.

  • Drawing a Motion path

    Hi fellows!!  I would like to ask please, if there's any way which allow me to draw an arbitrary line with the pencil tool for instance, and then tell to flash to use this path as a motion path for an object on the stage by creating a motion tween.  I know that this can be achieved by classic tween, but I look for a way to achieve the same effect but by using the new animation model of motion tween.  Cheers!!  Atar.

    Thanks for your response, but I'm already know that I can edit a motion path after it was created. But this process is harder than to draw the desired path with the pencil tool. I look for a way to a priori draw the path as I want.
    Cheers!!
    Atar.
    ב-24 ביול 2011, בשעה 17:04, kglad <[email protected]> כתב/ה:
    after creating a motion tween you can edit the path so it matches what you want.
    >

  • Does SQL Developer support a default Path to SQL scripts

    Just started using SQL Developer.
    In the past, I created shortcuts on my PC desktop to run SQLPLUS to the different
    instances as follows:
    1. Create a shortcut to PLUS80W.exe
    2. Set the property "Start in" to a directory where the SQL scripts are located.
    3. Add the login/password@instance to the end of the shortcut.
    In this way, ypu only needed to click on the shortcut to log into SQLPLUS and run your
    scripts via @script.sql etc.
    Can you setup a default path to SQL scripts SQL Developer so that it can locate
    the scripts on your PC ?

    I did notice in version 13.43 that if you close SQL Developer with a SQL script open in the SQL Worksheet, when you startup SQL Developer the next time it automatically opens the file in the SQL Worksheet with no database connection. It also sets the default path for SQL scripts to be the directory where your open SQL file resides. If you right-click in the SQL Workshop and then click on "Open File" the directory defaults to the directory of the SQL file that is open.
    Mike

  • Create a pen path with an action

    I can not save an action that create a pen path. Have you idea to resolve it?
    Thank you
    Marco

    You can save any path that you generate as a "Shape". This Shape can then be loaded in as part of your Action. Shapes are available if you select the Custom Shape Tool (under the U key).

  • I just tried to copy a folder to a pen drive from my mac. It transferred fine. I then ejected the pen drive then pulled it out. When I pulled it out it said it had not ejected correctly despite me just Doing this. The folder is now missing from both! Help

    I just copied a folder from my desktop to my pen drive. It transferred fine. I then ejected the pen drive then pulled it out. On doing so it said it had not been ejected properly!!!!! The folder is now missing from my computer and the pen drive. Pulling my hair out please help!

    When youi say Eject, the RAM copy of the Directory is written back to the drive. On a pen drive, this can take several seconds.
    If you get too excited and don't wait those few seconds, the directory write will be incomplete, and the drive will lose its integrity or lose files or both.

  • It's simple... I want the Illustrator pen tool to ALWAYS make corner annchor points and NEVER smooth.  Right now I have to convert every single one of them, or I have to do a work around every time I draw a line and make one of the handles disappear.  Is

    It's simple... I want the Illustrator pen tool to ALWAYS make corner annchor points and NEVER smooth.  Right now I have to convert every single one of them, or I have to do a work around every time I draw a line and make one of the handles disappear.  Is there some simple setting out there that will just "make it so?"@

    The video I am watching this guy is just dragging every line to make curves.  And every anchor point is a corner.  He is not switching back and forth between the pen and the anchor points tool, and he is not using the convert points tool.  He draws a curved line and starts another straight line only to curve it with a click and a drag.  It is super efficient, and I could save a world of time if I could figure out what he is doing.

  • Has anyone run into the I/O error 52 when trying to load something from a relative path in extend script?

    I'm having issues when loading something in a relative path through a script, on my computer I have no issues, but on 2 other devices at work, it's not working. Even at home on a PC and mac I haven't run into problems, anyone have insight on this?
    Here's where it fails:
    #include common.jsx
    It's loading this in the same path another script is called from. Thoughts?

    I remembered we have weird permission issues at work. Somewhere between my Home Windows 8 machine(horrible permissions issues with network), my home mac, email and my work computer, some permission got out of whack. The workaround for this was copying the file to my desktop, back to the exact same spot on the network. This resolved all issues.

  • Set file path in report scripts

    Hi All,
    Is it possible to set the file path to save the extracted data in report scripts, if so please let me know how to do it.
    We can choose the path when executing the script in script editor but how to set the file path in the script itself.
    Thanks in Advance

    You cannot set in in the report script itself.
    But rather you can set the output file and path where the output should be extracted.
    1. When you manually run from EASS console, you can specify the path and the file name
    2. When you use Maxl to run a report script, you can specify.
    Have a look at the Export Data
    Hope it helps
    Regards
    Amarnath
    ORACLE | Essbase

Maybe you are looking for

  • Adobe Photoshop Elements 10 wont open

    Ive intalled the Adobe Photoshop Elements 10 but when i go to open the program it says it cant find the shortcut. How do i open up the program now?

  • Unable to uninstall iTunes missing iTunes.msi

    path missing for itunes.msi. tried to uninstall and re-install but cannot successfully uninstall itunes. All files are still on computer except the main iTunes icon - apparently the msi file.

  • The install trail of BI extractor and impact for the application area

    Hi, I've heard BI extractor was newly installed to our system. And I have been investigating the impact from installing BI extractor. My qustions are; Do you know transaction codes or something to see how BI extractor is installed? Do you think BI ex

  • How to use h:message to display HTML code in message from property file

    I am using <h:message for="somecomponentid"/> to display the error message for a validator attached to a component and the error message which resides in message property file contains HTML elements like <br> and The HTML doesnt get displayed properl

  • Naming method

    Hi, we are taking into consideration the possibility to use directory or nis naming methods. Do these types of naming methos have disadvantages when compared to local naming (TAF support, client load balancing,...)? thanks in advance