Last active
September 26, 2021 07:24
-
-
Save MizunagiKB/fdea31c2fe3c871c5a64c5eb41319cab to your computer and use it in GitHub Desktop.
特定のグループ名をPNG出力するARScript(要UTF-16LEで保存)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//=========================================================================== | |
//=========================================================================== | |
// ArtRage Script File. | |
//=========================================================================== | |
//=========================================================================== | |
//=========================================================================== | |
// Version Block - Script version and ArtRage version: | |
//=========================================================================== | |
<Version> | |
ArtRage Version: ArtRage 7 | |
ArtRage Build: 7.1.3 | |
Professional Edition: Yes | |
Script Version: 1 | |
</Version> | |
//=========================================================================== | |
// Header block - Info about the painting/person who generated this script: | |
//=========================================================================== | |
<Header> | |
Script Feature Flags: 0x000000000 | |
</Header> | |
//=========================================================================== | |
// ArtRage project features. Sets the startup state of the script: | |
//=========================================================================== | |
//=========================================================================== | |
// Script data follows: | |
//=========================================================================== | |
<Events> | |
string layer_name_to_index(string name){ | |
int n = 0; | |
for(n = 0; n < LayerCount(); n++) { | |
if(name == LayerName(n)) return n; | |
} | |
return 65535; | |
} | |
int layer_index_to_name(int layer_index) { | |
int n = 0; | |
for(n = 0; n < LayerCount(); n++) { | |
if(layer_index == n) return LayerName(n) | |
} | |
return ""; | |
} | |
int MergeGroupLayer(string sLayerPrefix, stringarray ary_layer_name, flagarray ary_layer_show) { | |
int layer_index = 0; | |
int nPrefixLength = sLayerPrefix.Length(); | |
for(layer_index = 0; layer_index < LayerCount(); layer_index++) { | |
string layer_name = LayerName(layer_index); | |
flag layer_show = LayerVisible(layer_index); | |
string sName = layer_name.Left(nPrefixLength); | |
int undo_count = 0; | |
sName.ToLower(); | |
if(sName == sLayerPrefix) { | |
if(LayerType(layer_index) == 0) continue; | |
if(LayerType(layer_index) == 3) continue; | |
if(LayerType(layer_index) == 4) continue; | |
if(LayerType(layer_index) == 5) continue; | |
ary_layer_name.Add(layer_name); | |
ary_layer_show.Add(layer_show); | |
if(layer_show == false) | |
{ | |
Wait: 0.000s EvType: Command CommandID: CID_ToggleSpecificLayerVisible ParamType: LayerProp Value: { layer_index, 1 } | |
undo_count += 1; | |
} | |
Wait: 0.000s EvType: Command CommandID: CID_MergeSpecificGroup ParamType: uint32 Value: { layer_index } | |
undo_count += 1; | |
return undo_count; | |
} | |
} | |
return 0; | |
} | |
void main() { | |
string sBaseDir = "~/Desktop/"; | |
string sLayerPrefix = "page_"; | |
int nPrefixLength = sLayerPrefix.Length(); | |
int nMergeCount = 0; | |
int layer_index = 0; | |
int n = 0; | |
stringarray ary_layer_name; | |
flagarray ary_layer_show; | |
while(1) { | |
int n_result = MergeGroupLayer(sLayerPrefix, ary_layer_name, ary_layer_show); | |
if(n_result > 0) { | |
nMergeCount += n_result; | |
} else { | |
break; | |
} | |
} | |
for(layer_index = 0; layer_index < LayerCount(); layer_index++) { | |
string sLayerName = LayerName(layer_index); | |
string sName = sLayerName.Left(nPrefixLength); | |
sName.ToLower(); | |
if(sName == sLayerPrefix) { | |
Wait: 0.000s EvType: Command CommandID: ExportLayer Idx: layer_index Channels: NO Path: sBaseDir + layer_index + ".png" | |
} | |
} | |
for(n = 0; n < nMergeCount; n++) { | |
Wait: 0.000s EvType: Command CommandID: Undo | |
} | |
for(n = 0; n < ary_layer_name.GetSize(); n++) { | |
string layer_name = ary_layer_name[n]; | |
flag layer_show = ary_layer_show[n]; | |
layer_index = layer_name_to_index(layer_name); | |
if(layer_index < 65536) { | |
Wait: 0.000s EvType: Command CommandID: CID_ToggleSpecificLayerVisible ParamType: LayerProp Value: { layer_index, layer_show } | |
} | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment