PDA

View Full Version : Merging Multiple Layers



terrygillooly
08-04-2011, 03:57 PM
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!

terrygillooly
08-06-2011, 10:02 AM
Here's the code, by the way.



//================================================== =========================
//================================================== =========================
// 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

Lima
08-06-2011, 10:22 AM
Hey, great stuff. Wow, terrific Terry. Thanks.

MSIE
08-07-2011, 12:07 AM
thank you! very useful script - works like a charm on my paintings :D :)