ArtRage 5 Product PageArtRage Lite Product PageArtRage for iOS Product PageArtRage for Android Product PageArtRage  Android Oil Painter Free Product PageArtRage  Free Demos Page

Results 1 to 4 of 4

Thread: Merging Multiple Layers

  1. #1
    Join Date
    Feb 2010
    Location
    Nevada
    Posts
    139

    Merging Multiple Layers

    Of course we already can merge multiple layers in ArtRage, but what if we want to keep those hidden layers? This script will merge all the visible layers in your painting, while leaving the hidden layers intact.

    But wait! There's more!

    There's also an option to keep a copy of the layers being merged.

    Word of caution: I have tested this script on my paintings, but not on yours. Please be sure to save your work before running this script!
    Attached Files Attached Files
    Cat Boxes, a web comic

  2. #2
    Join Date
    Feb 2010
    Location
    Nevada
    Posts
    139
    Here's the code, by the way.

    Code:
    //===========================================================================
    //===========================================================================
    //                            ArtRage Script File.
    //===========================================================================
    //===========================================================================
    
    
    //===========================================================================
    // Version Block - Script version and ArtRage version:
    //===========================================================================
    
    <Version>
        ArtRage Version: ArtRage 3 Studio Pro
        ArtRage Build: 3.5.1
        Professional Edition: No
        Script Version: 1
    </Version>
    
    
    //===========================================================================
    // Header block - Info about the painting/person who generated this script:
    //===========================================================================
    
    <Header>
        // === Project data
        Painting Name: "untitled"
        Painting Width: 900
        Painting Height: 321
        Painting DPI: 299
        Mask Edge Map Width: 954
        Mask Edge Map Height: 862
        // === Author data
        Author Name: "Ti-Chen Feng"
        Script Name: "MultiMerge"
        Comment: "Merges visible Paint, Text, and Sticker layers while keeping hidden layers."
        Script Type: ""
        Script Feature Flags: 0
    </Header>
    
    
    
    //===========================================================================
    // Script data follows:
    //===========================================================================
    
    <Events>
    int nUp
    int nDown
    int nTop = LayerCount()-1
    int nBot = 0
    flag fCopy = YES
    flag fMerge = NO
    
    fCopy = YesNoBox("Retain copy of merged layers?")
    
    
    //Procedure: Starting from top layer and working down, loop through layers: 
    // ignore invisible layers; ignore group (1,2,3) layers.
    
    //Find first eligible layer (visible && paint/text/sticker)
    for ( nUp=nTop; nUp>nBot; nUp-- )  {
      if( LayerVisible(nUp) && ( LayerType(nUp)==0 || LayerType(nUp)>3 ) )  break
    }
    
    //Find second eligible layer (visible && paint/text/sticker); merge it
    for ( nDown=nUp-1; nDown>=nBot; nDown--)  {
      if( LayerVisible(nDown) && ( LayerType(nDown)==0 || LayerType(nDown)>3 ) )  {
        //If requested, duplicate nUp and nDown
        if( fCopy )  {
          Wait: 0    EvType: Command    CommandID: CID_DuplicateSpecificLayer    ParamType: uint32    Value: { nUp }
          Wait: 0    EvType: Command    CommandID: CID_DuplicateSpecificLayer    ParamType: uint32    Value: { nDown }
          Wait: 0    EvType: Command    CommandID: CID_MoveSpecificLayer    ParamType: LayerTwoOp    Value: { nDown, nDown+1 }
          nUp=nUp+2
          nTop++
        }
      //eep! merge
      Wait: 0    EvType: Command    CommandID: CID_MoveSpecificLayer    ParamType: LayerTwoOp    Value: { nDown, nUp-1 }
      Wait: 0    EvType: Command    CommandID: CID_MergeSpecificLayerDown    ParamType: uint32    Value: { nUp }
      //update values
      nUp--
      nDown--
      fMerge = YES
      break
      }
    }
    
    
    //Begin main loop: same thing we just did, except without duplicating nUp
    //(Yeah, this is pretty strange programming; I probably should used a function call or an if statement.)
    for ( nDown=nDown; nDown>=nBot; nDown--)  {
      if( LayerVisible(nDown) && ( LayerType(nDown)==0 || LayerType(nDown)>3 ) )  {
        if( fCopy )  {
          Wait: 0    EvType: Command    CommandID: CID_DuplicateSpecificLayer    ParamType: uint32    Value: { nDown }
          Wait: 0    EvType: Command    CommandID: CID_MoveSpecificLayer    ParamType: LayerTwoOp    Value: { nDown, nDown+1 }
          nUp++
        }
      //eep! merge
      Wait: 0    EvType: Command    CommandID: CID_MoveSpecificLayer    ParamType: LayerTwoOp    Value: { nDown, nUp-1 }
      Wait: 0    EvType: Command    CommandID: CID_MergeSpecificLayerDown    ParamType: uint32    Value: { nUp }
      //update values
      nUp--
      }
    }
    
    //For charm's sake, set the merged layer name
    if( fCopy && fMerge )  Wait: 0    EvType: Command    CommandID: LayerName    Idx: nUp    Name: "Merge Layer"
    
      
    //110803
    Cat Boxes, a web comic

  3. #3
    Join Date
    Mar 2009
    Location
    Rio de Janeiro
    Posts
    5,897
    Hey, great stuff. Wow, terrific Terry. Thanks.

  4. #4
    Join Date
    Aug 2007
    Location
    Germany
    Posts
    1,070
    thank you! very useful script - works like a charm on my paintings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •