Using Javascript to rasterize a layer and maintain its position with other layers.

Trying to use javascript to rasterize just the contents of a certain layer by its name.
It needs to maintain its position.
I've sort of cobbled a script, but it keeps moving the rastered art to the top layer.
Ex, top down i have Layer 4, RasterizeMe, Layer 2, Layer 1. 
The rastered contents end up on Layer 4
Any help would be apprecieated, or if theres a better method of doing this.
//  Rasterize Layer by name
    if ( app.documents.length > 0 ) {
        doc = app.activeDocument;
        if(!doc.saved){
            Window.alert("This script needs to modify your document. Please save it before running this script.");
        }else{
            createRasterLayer(doc);
    }else{
        Window.alert("You must open at least one document.");
function createRasterLayer(doc){
    var totalLayers = doc.layers.length;  //get the total number of layers in the active document
    for ( var i = 0 ; i < totalLayers ; i++){  //looping through layers            
        var currentLayer = doc.layers[i];
        var tempItem;
        if(currentLayer.visible == false) continue;   //We don't want to deal with hidden layers
        currentLayer.locked = false;                       //Unlock the layer if needed
        var layerName = new String( currentLayer.name );
        if ( layerName.indexOf("RasterizeMe") == 0 ) {
            currentLayer.hasSelectedArtwork = true;   //Select ALL in the layer
            if(doc.visibleBounds[2] == 0) continue;   // ignore empty layers
            var newoptions = new RasterizeOptions; 
            newoptions.resolution = 350;
            if ( doc.selection.length > 0 ) {
                newGroup = app.activeDocument.groupItems.add();
                for ( z = 0; z < doc.selection.length; z++ ) {
                    doc.selection[z].move( newGroup, ElementPlacement.INSIDE);
                doc.rasterize (newGroup, newGroup.visibleBounds, newoptions);

you're adding the group to the document, it will be the top most object on the top most layer
newGroup = app.activeDocument.groupItems.add();
use this to add the group to the current layer
newGroup = currentLayer.groupItems.add();
or if theres a better method of doing this.
I would
- loop through all layers,
- hide them all, except the one you want to rasterize,
- Rasterize the document
- unhide layers

Similar Messages

  • I am trying to use java  file as Model layer and jsf as presentation layer

    I am trying to use java file as Model layer and jsf as presentation layer and need some help
    I successfully get the value of h:outputText from java file by doing simple binding operation but I am facing problems when I am trying to fill h:dataTable
    I create java file
    package oracle.model;
    import java.sql.;*
    import java.util.;*
    *public class TableBean {*
    Connection con ;
    Statement ps;
    ResultSet rs;
    private List perInfoAll = new ArrayList();
    *public List getperInfoAll() {*
    perInfoAll.add(0,new perInfo("name","username","blablabla"));
    return perInfoAll;
    *public class perInfo {*
    String uname;
    String firstName;
    String lastName;
    *public perInfo(String firstName,String lastName,String uname) {*
    this.uname = uname;
    this.firstName = firstName;
    this.lastName = lastName;
    *public String getUname() {*
    return uname;
    *public String getFirstName() {*
    return firstName;
    *public String getLastName() {*
    return lastName;
    right click on the file and choose 'create data control'
    then i wrote the jsf file:
    *<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>*
    *<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>*
    *<f:view>*
    *<h:dataTable id="dt1" value="#{bindings.perInfoAll}"*
    var="item" bgcolor="#F1F1F1" border="10"
    cellpadding="5" cellspacing="3" rows="4" width="50%"
    dir="LTR" frame="hsides" rules="all"
    *>*
    *<f:facet name="header">*
    *<h:outputText value="This is 'dataTable' demo" id="ot6"/>*
    *</f:facet>*
    *<h:column id="c2">*
    *<f:facet name="header">*
    *<h:outputText value="First Name" id="ot1"/>*
    *</f:facet>*
    *<h:outputText style="" value="#{item.firstName}"*
    id="ot2"/>
    *</h:column>*
    *<h:column id="c4">*
    *<f:facet name="header">*
    *<h:outputText value="Last Name" id="ot9"/>*
    *</f:facet>*
    *<h:outputText value="#{item.lastName}" id="ot8"/>*
    *</h:column>*
    *<h:column id="c3">*
    *<f:facet name="header">*
    *<h:outputText value="Username" id="ot7"/>*
    *</f:facet>*
    *<h:outputText value="#{item.uname}" id="ot4"/>*
    *</h:column>*
    *<f:facet name="footer">*
    *<h:outputText value="The End" id="ot3"/>*
    *</f:facet>*
    *</h:dataTable>*
    *</center>*
    *</af:document>*
    *</f:view>*
    but nothing is appear in my table
    I know that there is something wrong in calling the binding object
    I need help pls and where can i find some help to deal with another tag types
    thanks

    i dragged the "perInfoAll" from my "Data Controls" and choosed adf table (even I know that new table with adf tags well be generated and i want table with jsf tags)
    and this code is generated
    *<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"*
    *"http://www.w3.org/TR/html4/loose.dtd">*
    *<%@ page contentType="text/html;charset=UTF-8"%>*
    *<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>*
    *<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>*
    *<%@ taglib uri="http://xmlns.oracle.com/adf/faces/rich" prefix="af"%>*
    *<f:view>*
    *<af:document id="d1">*
    *<af:messages id="m1"/>*
    *<af:form id="f1">*
    *<af:table value="#{bindings.perInfoAll1.collectionModel}" var="row"*
    *rows="#{bindings.perInfoAll1.rangeSize}"*
    *emptyText="#{bindings.perInfoAll1.viewable ? 'No data to display.' : 'Access Denied.'}"*
    *fetchSize="#{bindings.perInfoAll1.rangeSize}"*
    *rowBandingInterval="0"*
    *selectionListener="#{bindings.perInfoAll1.collectionModel.makeCurrent}"*
    *rowSelection="multiple" id="t1">*
    *<af:column sortProperty="uname" sortable="false"*
    *headerText="#{bindings.perInfoAll1.hints.uname.label}"*
    *id="c1">*
    *<af:inputText value="#{row.bindings.uname.inputValue}"*
    *label="#{bindings.perInfoAll1.hints.uname.label}"*
    *required="#{bindings.perInfoAll1.hints.uname.mandatory}"*
    *columns="#{bindings.perInfoAll1.hints.uname.displayWidth}"*
    *maximumLength="#{bindings.perInfoAll1.hints.uname.precision}"*
    *shortDesc="#{bindings.perInfoAll1.hints.uname.tooltip}"*
    *id="it3">*
    *<f:validator binding="#{row.bindings.uname.validator}"/>*
    *</af:inputText>*
    *</af:column>*
    *<af:column sortProperty="firstName" sortable="false"*
    *headerText="#{bindings.perInfoAll1.hints.firstName.label}"*
    *id="c2">*
    *<af:inputText value="#{row.bindings.firstName.inputValue}"*
    *label="#{bindings.perInfoAll1.hints.firstName.label}"*
    *required="#{bindings.perInfoAll1.hints.firstName.mandatory}"*
    *columns="#{bindings.perInfoAll1.hints.firstName.displayWidth}"*
    *maximumLength="#{bindings.perInfoAll1.hints.firstName.precision}"*
    *shortDesc="#{bindings.perInfoAll1.hints.firstName.tooltip}"*
    *id="it2">*
    *<f:validator binding="#{row.bindings.firstName.validator}"/>*
    *</af:inputText>*
    *</af:column>*
    *<af:column sortProperty="lastName" sortable="false"*
    *headerText="#{bindings.perInfoAll1.hints.lastName.label}"*
    *id="c3">*
    *<af:inputText value="#{row.bindings.lastName.inputValue}"*
    *label="#{bindings.perInfoAll1.hints.lastName.label}"*
    *required="#{bindings.perInfoAll1.hints.lastName.mandatory}"*
    *columns="#{bindings.perInfoAll1.hints.lastName.displayWidth}"*
    *maximumLength="#{bindings.perInfoAll1.hints.lastName.precision}"*
    *shortDesc="#{bindings.perInfoAll1.hints.lastName.tooltip}"*
    *id="it1">*
    *<f:validator binding="#{row.bindings.lastName.validator}"/>*
    *</af:inputText>*
    *</af:column>*
    *</af:table>*
    *</af:form>*
    *</af:document>*
    *</f:view>*
    but when run it i see the following errors
    *Class oracle.adf.model.adapter.bean.BeanDataControl can not access a member of class nl.amis.hrm.EmpManager with modifiers "private"*
    *Object EmpManager of type DataControl is not found.*
    *java.lang.NullPointerException*
    *Class oracle.adf.model.adapter.bean.BeanDataControl can not access a member of class nl.amis.hrm.EmpManager with modifiers "private"*
    *Object EmpManager of type DataControl is not found.*
    *java.lang.NullPointerException*
    :(

  • Is there a way to use a namespace, such as "Library", and have a program with a different namespace include the Library namespace?

    For many years, I have maintained a library of often used functions for C++.  This has become more challenging with the required namespace for C#. 
    Is there a way to use a namespace, such as "Library", and have a program with a different namespace include the Library namespace?
    bhs67

    You could create a class X in a namspace Y in a C# class library project. You can then add a reference to this class library project/assembly from every application in which you intend to use the class X in namespace Y.
    You don't add references to namespace, you add references to assemblies in .NET. You can then use a class in namespace Y of any referenced assembly by adding a using directive at the top of the code file in which you reference the class:
    using Y;
    Please remember to close your threads by marking helpful posts as answer.

  • How to use multiple JREs (1.5.0_20 and 1.6.0_07) with Internet Explorer 8?

    Hi!
    Question about the problem mentioned in subject.
    I have configured that JNLP opens with 1.5 version, both versions are enabled in Java Control Panel Runtime Settings but when I try to start a desktop java console says:
    Java Web Start 1.5.0_22
    Using JRE version 1.6.0_07 Java HotSpot(TM) Client VM
    And the opening of the desktop creates an exception:
    Java Web Start - Invalid Argument Error
    TooManyArgumentsException[ Too many arguments supplied: {C:\WINDOWS\Temporary, Internet, Files\Content.IE5\....
    I'm trying to open my desktop with 1.5 version and other programs with 1.6 version. What is it that I still need to do? I'm kind of confused with this. Some of my collagues have succeeded with this and some doesn't, with the same configuration.
    So the question is, how to use multiple JREs with IE8 so that one application uses 1.5 version and others 1.6 version?
    Br,
    Katri
    Edited by: ka**** on 09-Mar-2011 01:16
    Edited by: ka**** on 09-Mar-2011 03:16

    ka**** wrote:
    ..Question about the problem mentioned in subject.No "Using multiple JREs (1.5.0_20 and 1.6.0_07) with Internet Explorer 8" is a statement. To transform it to a question would be something like "How to use multiple JREs (1.5.0_20 and 1.6.0_07) with Internet Explorer 8?".
    Once you can come up with an actual question, I might look at this more closely.

  • When i use view as list in finder and open a folder with many files i cant right click with mouse without selecting or highlighting a file....i just want to right click to paste an item or create a new folder...what can i do?

    When i use view as list in finder and open a folder with many files i cant right click with mouse without selecting or highlighting a file....i just want to right click to paste an item or create a new folder...what can i do?

    Thx for that im gonna try it....but is there a way to do it without using toolbar or cmd-c...? i mean using only the mouse?why does it have to highlight the file even though i click a bit next to it....?using icon view i can right click next to the folder and i wont have a problem but with list view that i prefer using it will highlight the whole row.....and i dont find free space to right click cause i got many files

  • I am using an early 2008 MacBook Pro and am having issues with it deleting text on its own (in word, emails, etc.). As I am typing it all of a sudden starts deleting and I can't stop it. What can I do?

    I am using an early 2008 MacBook Pro and am having issues with it deleting text on its own (in word, emails, etc.). As I am typing it all of a sudden starts deleting and I can't stop it. This happened once before and it was due to a buldging battery pressing on the track pad. I checked the battery and it appears to be fine. What can I do?

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up guest users” (without the quotes) in the search box. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click Log in.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode.
    Test while in safe mode. Same problem?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Hi, Using MAC OSX 10.6.8 and have intermittent issues with receiving new emails - sending is OK. I've tried the workarounds (take offline & take online), quitting mail etc - no luck. Any suggestions?

    Hi, I'm using MAC OSX 10.6.8 and have intermittent issues with receiving new emails - sending is OK. I've tried the workarounds (take offline & take online), quitting mail etc - no luck. Have cleared space, checked Window - Doctor and server has green light.  Mail Activity shows 47 emails waiting to download, iPad and iPhone download them all OK - no extra big files stopping the download either.    In the past, quitting mail has worked, but not today... Any suggestions?

    Hi, I'm using MAC OSX 10.6.8 and have intermittent issues with receiving new emails - sending is OK. I've tried the workarounds (take offline & take online), quitting mail etc - no luck. Have cleared space, checked Window - Doctor and server has green light.  Mail Activity shows 47 emails waiting to download, iPad and iPhone download them all OK - no extra big files stopping the download either.    In the past, quitting mail has worked, but not today... Any suggestions?

  • I have a Nikon AW100 and I use a SanDisk for the memory and I download that with My Pictures and Videos but I cant get my videos onto IMovie

    I have a Nikon AW100 and I use a SanDisk for the memory and I download that with My Pictures and Videos but I cant get my videos onto IMovie

    Hi
    I import all from my Nikon - into iPhoto
    Then closing it and opening iMovie
    In the Event window like
    • iPhoto-videor - Here I find mine.
    Yours Bengt W

  • I am using the trial version of CC and cannot get the auto blend layers working despite following many videos on youtube etc. I have selected all layers but no matter which order I select etc all I get is an output of the first file in the stack - help!!

    I am using the trial version of CC and cannot get the auto blend layers working despite following many videos on youtube etc. I have selected all layers but no matter which order I select etc all I get is an output of the first file in the stack - help!!

    <moved from Adobe Creative Cloud to Photoshop General Discussion>

  • When I'm using a browser (like Safari) in Yosemite, how can I shrink it and share my desktop with other applications?

    I have an iMac, and after installing Yosemite (OS 10.10), all my browsers (like Safari) no longer share the screen with other applications, like Word or even Calculator.  How can I shrink Safari (or any browser) and share my desktop with other applications?

    When I'm using any browser (at the moment, it's Safari), I am unable to resize the window.  The browser BECOMES my entire desktop.  And if I open another application, suddenly the browser vanishes to the right, so I can only see the other app.  AND my dock disappears into a solid black space below the screen, which I can penetrate with my curser (after dragging the curser back and forth above and below the black space until the dock eventually reappears.  But if I select any app in the browser to open, then Safari vanishes instantly to the right of the screen.  I've tried to resize Safari (and Firefox and Chrome) by moving the curser to the bottom right of the browser, but that old standby doesn't seem to work anymore.  The browser takes up all of the screen, except for a small portion of the top, where my curser can reveal Safari's old menus, and the bottom of the screen, which is entirely black until I can locate my dock by dunking the curser up and down in the black ooze.
    I really want the old convenience of my Mac, where several programs can open side by side, but Yosemite seems to have precluded that possibility.  What can I do?

  • When I'm using a browser (like Safari), how can I shrink it and share my desktop with other applications?

    I have an iMac, and after installing Yosemite (OS 10.10), all my browsers (like Safari) no longer share the screen with other applications, like Word or even Calculator.  How can I shrink Safari (or any browser) and share my desktop with other applications?

    Yes, mission control threw everything across the screen (which is way beyond anything I could figure out), but the real answer I needed came from Apple Tech Support, which I finally called, and I learned about the two arrows in the top righthand corner, when I held the cursor there, which turned blue and resized and released the browser from total domination of the screen.  Those two, opposite-pointing arrows allowed me to shrink the browser and let other applications be seen on the desktop.  But thank you for extending a helpful tip, which I can use another time.

  • I have not used ipad from last 1 year and now its not starting any suggestion how to start, i have not used ipad from last 1 year and now its not starting any suggestion how to start

    i have not used ipad from last 1 year and now its not starting any suggestion how to start,

    Using the Supplied iPad charger, Connect it to the mains for at least 60 minutes...
    Then try to turn it on.

  • HT4060 Can I use the power cord (30-pin and USB) that came with iPad 2 to charge it in my car's USB port?

    Can I use the power cord (30-pin and USB) that came with iPad 2 to charge it in my car's USB port?  Or do I need to purchase one of those cigarette lighter charging devices?  Thanks!

    You'd have to read your car manual but chances are it won't put out enough power for the iPad. The car is likely set up to charge a phone, most of which typically want half the power an iPad wants.
    I think your  options are to get a cigarette lighter looking charger, making sure it's powerful enough for an iPad...or you can get power inverters for about $25, where they plug into the cigarette lighter/power point and have a normal household type outlet on the other end. Then you'd just plug your charger  in like you would at home.
    Another option would be to look for something like a Zagg Sparq, which is a battery operated charger...plug the Sparq into the outlet at home. Its battery holds a charge and you can use that to charge your device. (zagg isn't the only manufacturer of such a device, Targus has one as well). Just look for portable chargers.
    The key to remember is to make sure it's rated for an iPad, which will want more power than a cell phone.

  • Can i use The iPod shuffle cable (3rd and 4th generation) comes with a 45 mm USB cable for syncing and charging. with 2nd generation ipod?

    can i use The iPod shuffle cable (3rd and 4th generation) comes with a 45 mm USB cable for syncing and charging. with 2nd generation ipod?

    thanks

  • How do I subtract the shape of a layer (a scanned shape) from my other layers - but when the shape hasn't been drawn in photoshop

    Im trying to subtract a shape I have previously painted and scanned in from my other layers...can this be done?

    If this is the effect you want, add a white bottom layer, and create a mask of the heart art to drop it out of image layers
    or... do  you want color only in the heat shape and the rest of the page white?

Maybe you are looking for

  • User exit to update the incompletion log in sales order for pricing error

    Hi experts, I have to check the some mandotory pricing conditions in sales order, if that conditions are not exist in sales order then i need to show the information message as well as i need to update it in incompletion log of sales order. (incoplet

  • Set User Setting from OnAfterLogin

    Scenario: All gadgets/portlets will want to know which group a specific user is in. We are importing the users from a Windows NT domain. We know we can query the groups using the PRC in a portlet, but we'll also be using GDK gadgets, so we would need

  • Run program at shutdown

    I think this is asked about fairly often. I would like to run a program (SuperDuper!) at shutdown. Obviously, it should be possible to customize the OSX shutdown procedure to do what I need. Before I dig into this, any advice? I don't know much about

  • Can I swap my upgrade?

    I have a Verizon account that I've had for about 6-7 years. I have two lines on my account - One that is a Tablet (Samsung Galaxy) that is a 2GB/mo data plan (no voice), and the other is an iPhone 4S that has unlimited data and 450 minutes/month. I w

  • Dual band support in UK

    i own a nokia 3300. I would be flying to UK soon. I understand that 3300 has dual band support. I wanted to confirm whether I can use it in UK too.