Layers of an InDesign® document
Layers of an InDesign® document
static int layer::count()
How many layers does the active document have?
Name | Type | Default | Description |
Return | int | Number of layers of the active document |
Show the number of layers of the current document in a message.
int main ()
{
showmessage ("%d", layrs::count ());
return 0;
}
static char* layer::front_name(char* s = 0)
Get the name of the active document layer.
In InDesign® (Desktop) this is the active layer of the current front document.
In InDesign® Server, the current front document is the last document opened and the active layer is the layer that was last defined in this document with layer::select. The call of layer::select may have been in a previous (also InDesign® Desktop) session. If layer::select has never been executed in the current front document, the empty string is returned.
If the document has only one layer, this layer is automatically used as the active layer. The call of layer::select is not necessary in this case.
Name | Type | Default | Description |
Return | String or char* | s is returned for your convenience. | |
s | String or char* | 0 | Reserved memory for the layer name. 0 : [Since v4.3 R36166] The variable may be 0 or missing, then applies: The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values. |
Show the name of the current layer in a message.
int main ()
{
showmessage ("--%s--", layer::front_name ());
return 0;
}
In the example, layer::front_name is used in a Python script that requires the name of the active layer (even if only in a showMwssage).
#!py
import comet
def main(): comet.runCScript ("int main ()\ {\ char lname [512];\ \ set_script_clipboard (\"myLayer\", layer::front_name (lname));\ return 0;\ }") frontLayer = comet.getScriptClipboard ('myLayer') comet.showMessage (f'Current Layer is now {frontLayer}') return 0
static int layer::rename_all(char* prefix = 0)
Rename all layers according to their current order. The passed prefix is used as the basis for the new layer names. The topmost layer (the one that covers all the others) is given the largest number. In a document with L layers, this results in the following new names:
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
prefix | String or char* | "" | Name base. If the name is empty, the InDesign® default name 'Layer' is used. |
Change all layer names according to their current order to MMM 5, MMM 4, ..., MMM 1.
int main ()
{
layer::rename_all ("MMM");
}
static int layer::sort()
Sort all layers of the current document in descending order by name. Sorting is case insensitive. Here is a before/after screenshot:
Name | Type | Default | Description |
Return | int | 0 or ErrorCode |
Sort all document layers by name.
int main () { layer::sort (); return 0; }
static int layer::index(char* n)
What is the position of a layer? Positions are counted starting at 0 from the bottom. Layers with a higher index cover frames of layers with a lower index. If a layer is not found, -1 is returned.
Name | Type | Default | Description |
Return | int | 0-based index of layer or -1. | |
n | String or char* | - | Layer name |
Show the index of 'Layer 1' in a message:
int main () { showmessage ("%d", layer::index ("Layer 1"));
return 0; }
static char* layer::name(int nth, char* res)
Name of the nth layer. Positions are counted beginning at 0 from the bottommost layer. If there is no layer with the specified index, then the empty string will be returned.
Name | Type | Default | Description |
Return | String or char* | Parameter res with the name (or "" in case of any errors) of the nth layer | |
nth | int | - | 0-based index of the reqquested layer. -2 : Currently selected layer |
res | String or char* | - | Reserved memory for the layer name |
Show the name of the currently selected layer in a message.
int main () { char s[256];
showmessage ("'%s'", layer::name (-2, s)); return 0; }
static int layer::select_i(int index)
Activate a layer specified by its index. If the layer is not found, the method has no effect.
InDesign® Server as a faceless application cannot select a layer. The layers name is set as a document preference in here.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
index | int | - | 0-based layer index. |
Select the highest (topmost) layer of the current document.
int main () { layer::select_i (layer::count () - 1); return 0; }
static int layer::select(char* lname)
Activate a layer specified by name. If the layer is not found, the method has no effect.
InDesign® Server as a headless application cannot select a layer. The layers name is set as a document preference in this case and can then be queried (also in a later InDesign® session) with layer::front_name.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
lname | String or char* | - | Name of a layer |
The example shows the use of the function in a Python script. The name of the layer is transferred to the short cScript using the variable layerName here.
comet.runCScript ('int main () { layer::select (layerName); return 0; }', items=[('Ebene 3', 'layerName')])
static int layer::set_visible_i(int index, int vis)
Show or hide a layer specified by index.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
index | int | - | 0-based index of layer. -2 : Currently selected layer |
vis | int | - | Visibility to set 0 : hidden Otherwise : visible |
Make the current layer invisible:
int main () { layer::set_visible_i (-2, 0); return 0; }
static int layer::set_visible(char* nam, int vis)
Show or hide a layer specified by name.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
nam | String or char* | - | Name of a layer |
vis | int | - | Visibility to set 0 : Hide Otherwise : Show |
Make 'Layer 1' invisible.
int main ()
{
layer::set_visible ("Layer 1", 0);
return 0;
}
static int layer::remove_i(int index)
Delete a layer specified in your index. BDeleting a layer also deletes all frames on this layer.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode 1207 removeLayerErr : Error when removing the layer 1205 deleteLayerErr : The document now only has one layer. The given layer can therefore not be removed. |
|
index | int | - | 0-based index of layer to remove.
The command removes the given layer and all its contents! -2 : Currently selected layer |
Remove the current layer and all its contents.
int main () { layer::remove_i (-2); return 0; }
static int layer::remove(char* nname)
Delete a layer specified by its name. Deleting a layer also deletes all frames on this layer.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode 1207 removeLayerErr : Error when removing the layer 1205 deleteLayerErr : The document now only has one layer. The given layer can therefore not be removed. |
|
nname | String or char* | - | Name of the layer to remomve. |
Delete the layer ‘Layer 1’ and all its contents.
int main ()
{
layer::remove ("Layer 1");
return 0;
}
static int layer::merge(char* from, char* to)
Move the contents of the layer from to the layer to and remove layer from then. Both layers are defined by their names.
If the content of the layer from is to be preserved, please use the function layer::copy. If both layers are the same, the function only returns the error code 0 (Okay).
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | String or char* | - | Name of the layer whose objects are to be moved. After the content has been deleted, the layer itself is removed too. |
to | String or char* | - | Name of the target layer |
Copy the contents of Layer 2 to Layer 1 and then delete Layer 1.
int main () { layer::merge ("Layer 2", "Layer 1"); return 0; }
static int layer::merge_ni(char* from, int to)
Move the contents of the layer from to the layer to and remove layer from then. The first layer is given by its name, the second by an index.
If the content of the layer from is to be preserved, please use the function layer::copy_ni. If both layers are the same, the function only returns the error code 0 (Okay).
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | String oder char* | - | Name of the layer whose objects are to be moved. After the content has been deleted, the layer itself is removed too. |
to | int | - | 0-based index of target layer -2 : Currently selected layer |
Copy the content of Layer 2 into the current layer and then delete Layer 2.
int main ()
{
layer::merge_ni ("Layer 2", -2);
return 0;
}
static int layer::merge_ii(int from, int to)
Move the contents of the layer from to the layer to and remove layer from then. Both layers are identified by indexes.
If the content of the layer from is to be preserved, please use the function layer::copy_ii. If both layers are the same, the function only returns the error code 0 (Okay).
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | int | - | 0-based index of the layer whose objects are to be moved.
After the content has been deleted, the layer itself is removed too. -2 : Currently selected layer |
to | int | - | 0-based index of target layer -2 : Currently selected layer |
Copy the content of the topmost layer to the current layer and then remove the old topmost layer.
int main () { layer::merge_ii (0, -2); return 0; }
static int layer::merge_in(int from, char* to)
Move the contents of the layer from to the layer to and remove layer from then. The first layer is given by an index, the second by its name.
If the content of the layer from is to be preserved, please use the function layer::copy_in. If both layers are the same, the function only returns the error code 0 (Okay).
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | int | - | 0-based index of the layer whose objects are to be moved.
After the content has been deleted, the layer itself is removed too. -2 : Currently selected layer |
to | String oder char* | - | Name of target layer |
Copy the content of the current layer to Layer 1 and delete the current layer.
int main ()
{
layer::merge_in (-2, "Layer 1");
return 0;
}
static int layer::copy(
char* from,
char* to,
int exhaustive = 0,
int reconstruct = 0,
int completeProducts = 0)
Copy (duplicate) the content of the layer from to the layer to. Both layers are defined by their names. If both layers are the same, all frames of this layer are duplicated.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | String or char* | - | Name of the layer whose objects are to be duplicated. |
to | String or char* | - | Name of the target layer |
exhaustive | int | 0 | Due to a bug in InDesign® Server CS6 the Server may crash while executing this command.
Set exhaustive to 1 to avoid this error - we use a bypass in this case. 0 : default behavior 1 : use the bypass |
reconstruct | int | 0 | Recreate Comet groups, relink Comet notes and re-map repetition elements for the new frames? 0 : no 1 : yes Hidden Comet Notes are NOT duplicated! |
completeProducts | int | 0 | In case there are frames beloning to a Comet Group and NOT laying on the layer from,
shall I duplicate this too? 0 : no 1 : yes |
Duplicate the contents of Layer 2 into Layer 1.
int main () { layer::copy ("Layer 2", "Layer 1"); return 0; }
Dupliziere die aktuelle Ebene. Alle Cometgruppen werden dabei wiederhergestellt.
int main () { char frontname [4000]; char newname [4000]; char tmp [4000]; int index = 0;
// Get current front layer layer::front_name (frontname); index = layer::index (frontname);
// Create a new layer name and create the layer layer::default_name (sprintf (tmp, "%s Kopie", frontname), newname); layer::add_i (newname, index+1);
// Copy content layer::copy (frontname, newname, 1, 1);
return 0; }
static int layer::copy_ni(
char* from,
int to,
int exhaustive = 0,
int reconstruct = 0,
int completeProducts = 0)
Copy (duplicate) the content of the layer from to the layer to. The first layer is given by its name, the second by an index. If both layers are the same, all frames of this layer are duplicated.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | String oder char* | - | Name of the layer whose objects are to be duplicated. |
to | int | - | 0-based index of target layer -2 : Currently selected laye |
exhaustive | int | 0 | Due to a bug in InDesign® Server CS6 the Server may crash while executing this command.
Set exhaustive to 1 to avoid this error - we use a bypass in this case. 0 : default behavior 1 : use the bypass |
reconstruct | int | 0 | Recreate Comet groups, relink Comet notes and re-map repetition elements for the new frames? 0 : no 1 : yes Hidden Comet Notes are NOT duplicated! |
completeProducts | int | 0 | In case there are frames beloning to a Comet Group and NOT laying on the layer from,
shall I duplicate this too? 0 : no 1 : yes |
Duplicate the content of Layer 2 into the current layer.
int main ()
{
layer::copy_ni ("Ebene 2", -2);
return 0;
}
static int layer::copy_ii(
int from,
int to,
int exhaustive = 0,
int reconstruct = 0,
int completeProducts = 0)
Copy (duplicate) the content of the layer from to the layer to. Both layers are identified by indexes. If both layers are the same, all frames of this layer are duplicated.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | int | - | 0-based index of the layer whose objects are to be duplicated. -2 : Currently selected layer |
to | int | - | 0-based index of target layer -2 : Currently selected layer |
exhaustive | int | 0 | Due to a bug in InDesign® Server CS6 the Server may crash while executing this command.
Set exhaustive to 1 to avoid this error - we use a bypass in this case. 0 : default behavior 1 : use the bypass |
reconstruct | int | 0 | Recreate Comet groups, relink Comet notes and re-map repetition elements for the new frames? 0 : no 1 : yes Hidden Comet Notes are NOT duplicated! |
completeProducts | int | 0 | In case there are frames beloning to a Comet Group and NOT laying on the layer from,
shall I duplicate this too? 0 : no 1 : yes |
Duplicate the content of the topmost layer to the current layer.
int main () { layer::copy_ii (layer::count () -1, -2); return 0; }
static int layer::copy_in(
int from,
char* to,
int exhaustive = 0,
int reconstruct = 0,
int completeProducts = 0)
Copy (duplicate) the content of the layer from to the layer to. The first layer is given by an index, the second by its name. Both layers may be the same.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
from | int | - | 0-based index of the layer whose objects are to be duplicated. -2 : Currently selected layer |
to | String oder char* | - | Name of target layer |
exhaustive | int | 0 | Due to a bug in InDesign® Server CS6 the Server may crash while executing this command.
Set exhaustive to 1 to avoid this error - we use a bypass in this case. 0 : default behavior 1 : use the bypass |
reconstruct | int | 0 | Recreate Comet groups, relink Comet notes and re-map repetition elements for the new frames? 0 : no 1 : yes Hidden Comet Notes are NOT duplicated! |
completeProducts | int | 0 | In case there are frames beloning to a Comet Group and NOT laying on the layer from,
shall I duplicate this too? 0 : no 1 : yes |
Duplicate the content of the current layer into Layer 1.
int main ()
{
layer::copy_in (-2, "Ebene 1");
return 0;
}
static int layer::move(char* mv, char* behind)
Moving a layer. The mv layer is moved behind (under) the behind layer. The frames of the mv layer can thus be hidden by the frames of the behind layer. Both layers are defined by their names.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
mv | char* | - | Name of the layer to be moved |
behind | char* | - | Name of the layer behind which the layer mv is to be moved. "" or layer does not exist : mv becomes the new topmost layer |
Move Layer 1 to the top.
int main () { layer::move ("Layer 1", ""); return 0; }
static int layer::move_ni(char* mv, int behind)
Moving a layer. The mv layer is moved behind (under) the behind layer. The frames of the mv layer can thus be hidden by the frames of the behind layer. The first layer is defined by its name, the second by an index.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
mv | String or char* | - | Name of the layer to be moved |
behind | int | - | Index of the layer below which the layer mv should lie. -2 : Behind (under) current layer -1 or ≥ Number of layers : New topmost (foregrund) layer |
Make Level 2 the new topmost layer.
int main ()
{
layer::move_ni ("Ebene 2", -1);
return 0;
}
static int layer::move_ii(int mv, int behind)
Moving a layer. The mv layer is moved behind (under) the behind layer. The frames of the mv layer can thus be hidden by the frames of the behind layer. Both layers are defined via an index.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
mv | int | - | Index of the layer to be moved. -2 : Current layer |
behind | int | - | Index of the layer behind (under) which the layer should lie. -2 : Behind (under) current layer -1 or ≥ Number of layers: New topmost layer |
Make the current layer the topmost one.
int main () { layer::move_ii (-2, -1); return 0;
static int layer::move_in(int mv, char* behind)
Moving a layer. The mv layer is moved behind (under) the behind layer. The frames of the mv layer can thus be hidden by the frames of the behind layer. The first layer is defined by an inded, the second by its name.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
mv | int | - | Index of the layer which is to be moved. -2 : Current layer |
behind | String or char* | - | Name of the layer to move the layer behind. "" or layer does not exist : mv becomes new topmost layer |
Make the current layer the new topmost layer.
int main ()
{
layer::move_in (-2, "");
return 0;
}
static int layer::rename(char* oldName, char* newName)
Change the name of a layer.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
oldName | String or char* | - | Name of the layer the name of which is to be changed |
newName | String or char* | - | New layer name |
Rename Layer 1 to E1.
int main () { layer::rename ("Layer 1", "E1"); return 0; }
static int layer::rename_i(int index, char* newName)
Change the name of a layer given by an index.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
index | int | - | 0-based index of the layer whose name is to be changed. -2 : Currently selected layer |
newName | String or char* | - | New layer name |
Change the name of the topmost layer.
int main ()
{
layer::rename_i (layer::count () - 1, "Topmost Layer");
return 0;
}
Change the name of the lowest layer.
int main ()
{
layer::rename_i (0, "Bottommost Layer");
return 0;
}
static int layer::rename_prefixed(
char* oldName,
char* prefix,
int useGap = 1)
Change the name of a layer in accordance with a specified prefix. If the prefix is specified as 'Paul' for example, there is a layer with the name 'Paul 3', 'Paul 4' will be used as the new name.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
oldName | String or char* | - | Name of the layer whose name is to be changed |
prefix | String or char* | - | Prefix of the new layer name "" : Use the name that would also be used when creating a layer manually |
useGaps | int | 1 | Method for calculating the new name. The parameter is only evaluated if prefix is not empty. Assuming your document has the layer E1 and E3, you will get the following different results depending on useGaps: 0 : E4 1 : E2 |
Rename layer fff to Layer N. The value of N is automatically calculated from the existing layers of the document.
int main () { layer::rename_prefixed ("fff", "Ebene", 0); return 0; }
static int layer::rename_prefixed_i(
int index,
char* prefix,
int useGap = 1)
Change the name of a layer in accordance with a specified prefix. If the prefix is specified as 'Paul' for example, there is a layer with the name 'Paul 3', 'Paul 4' will be used as the new name. The layer is defined via an index.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
index | int | - | 0-based index of the layer whose name is to be changed. -2 : Currently selected layer |
prefix | String or char* | - | Prefix of the new layer name 0 or "" : Use the name that would also be used when creating a layer manually. |
useGaps | int | 1 | Method for calculating the new name. The parameter is only evaluated if prefix is not empty. Assuming your document has the layer E1 and E3, you will get the following different results depending on useGaps: 0 : E4 1 : E2 |
Rename the current layer to ‘Layer N’. The value of N is automatically calculated from the existing levels of the document.
int main ()
{
layer::rename_prefixed_i (-2, "Ebene", 0);
return 0;
}
static int layer::add(
char* newName,
char* behind,
int doSelect = 0,
char* outName = 0)
Create a new document layer behind a given layer.
Name | Type | Default | Description |
Return | int | 0 or Error Code | |
newName | String oder char* | - | Name of the new layer. If a layer already exists with the specified name
no new layer is created and the position of the existing layer remains unchanged. 0 or "" : Use the name that would also be used when creating a layer manually. |
behind | String oder char* | - | Name of the layer behind which the new layer should be located. If this layer is not found, the new layer will be created as the new topmost layer. |
doSelect | int | 0 | Should the layer be activated immediately? 0 : no 1 : yes Ignored by Illustrator. |
outName | String oder char* | 0 | Allocated memory for the name of the newly created layer. 0 : Ignore return value |
To run the script, you need a test document with at least 3 layers, one of which must be named "Layer 6". The document should also contain four frames whose UIDs you still need to enter in the calls to the mv function.
int mv (int uid, char* l, char * bkname, int bkindex) { ItemRef fr = item::alloc (); int result = 0; String lname = string::alloc (); String lname2 = string::alloc ();
item::define (fr, 0, uid);
if (strlen (bkname)) result = layer::add (l, bkname, 0, lname); else result = layer::add_i (l, bkindex, 0, lname);
printf ("# Frame %d : (%s)\n", uid, lname);
if (result == 0) { result = frame::move_to_layer (fr, lname, 0, 0); if (result != 0) { printf ("# Layoutrule 'Move to layer' : Ignoring error %d (%s)\n", result, serror (result)); } else { printf ("LAYER of %d : (%s)\n", uid, frame::get_layer (fr, lname2)); } }
printf ("\n"); string::release (lname); string::release (lname2); item::release (fr); return 1; }
int main () { mv (262, "", "Layer 6", 0); mv (305, "YY", "Layer 6", 0);
mv (464, "", 0, 2); mv (466, "ZZ", 0, 2); return 0; }
static int layer::add_i(
char* newName,
int index,
int doSelect = 0,
char* outName = 0)
Create a new document layer behind a layer given by its index.
Name | Type | Default | Description |
Return | int | 0 or Error Code | |
newName | String oder char* | - | Name of the new layer. If a layer already exists with the specified name
no new layer is created and the position of the existing layer remains unchanged. 0 or "" : Use the name that would also be used when creating a layer manually. |
behind | int | - | 0-based index, behind which the new layer should lie.
If this layer is not found, the new layer will be created as the new topmost layer. -2 : Aktuelle Ebene |
doSelect | int | 0 | Should the layer be activated immediately? 0 : no 1 : yes Ignored by Illustrator. |
outName | String or char* | 0 | Allocated memory for the name of the newly created layer. 0 : Ignore return value |
To run the script, you need a test document with at least 3 layers, one of which must be named "Layer 6". The document should also contain four frames whose UIDs you still need to enter in the calls to the mv function.
int mv (int uid, char* l, char * bkname, int bkindex) { ItemRef fr = item::alloc (); int result = 0; String lname = string::alloc (); String lname2 = string::alloc ();
item::define (fr, 0, uid);
if (strlen (bkname)) result = layer::add (l, bkname, 0, lname); else result = layer::add_i (l, bkindex, 0, lname);
printf ("# Frame %d : (%s)\n", uid, lname);
if (result == 0) { result = frame::move_to_layer (fr, lname, 0, 0); if (result != 0) { printf ("# Layoutrule 'Move to layer' : Ignoring error %d (%s)\n", result, serror (result)); } else { printf ("LAYER of %d : (%s)\n", uid, frame::get_layer (fr, lname2)); } }
printf ("\n"); string::release (lname); string::release (lname2); item::release (fr); return 1; }
int main () { mv (262, "", "Layer 6", 0); mv (305, "YY", "Layer 6", 0);
mv (464, "", 0, 2); mv (466, "ZZ", 0, 2); return 0; }
static int layer::add_prefixed(
char* prefix,
char* behind,
int doSelect = 0,
char* outName = 0,
int useGap = 1)
Create a new named/prefxied document layer behind a given layer.
Name | Type | Default | Description |
Return | int | 0 or Error Code | |
prefix | String oder char* | - | Name/prefix of the new layer. "" : Use the name that would also be used when creating a layer manually. |
behind | String oder char* | - | Name of the layer behind which the new layer should be located. If this layer is not found, the new layer will be created as the lowest layer. |
doSelect | int | 0 | Should the layer be activated immediately? 0 : no 1 : yes |
outName | String oder char* | 0 | Allocated memory for the name of the newly created layer. 0 : Ignore returned value |
useGaps | int | 1 | Method for calculating the new name. The parameter is only evaluated if prefix is not empty. Assuming your document has the layer E1 and E3, you will get the following different results depending on useGaps: 0 : E4 1 : E2 |
static int layer::add_prefixed_i(
char* prefix,
int behind,
int doSelect = 0,
char* outName = 0,
int useGap = 1)
Create a new named/prefxied document layer given by its index.
Name | Type | Default | Description |
Return | int | 0 or Error Code | |
prefix | String oder char* | - | Name/prefix of the new layer. If a layer already exists with the specified prefix
a new layer with the next counting number is created.
(If, for example, the prefix Lala is specified and the layers Lala, Lala 1 and Lala 30 exist, the layer Lala 31 will be created.) 0 or "" : If no name is specified, a new default name is determined. |
behind | int | - | 0-based index behind which the new layer should be located. If this layer is not found, the new layer is created as the lowest layer. |
doSelect | int | 0 | Should the layer be activated immediately? 0 : no 1 : yes |
outName | String oder char* | 0 | Allocated memory for the name of the newly created layer. 0 : Ignore returned value |
useGaps | int | 1 | Method for calculating the new name. The parameter is only evaluated if prefix is not empty. Assuming your document has the layer E1 and E3, you will get the following different results depending on useGaps: 0 : E4 1 : E2 |
static char* layer::default_name(
char* prefix,
char* newName,
int useGaps = 1)
Determine the next valid default name that can be used for a new layer.
Name | Type | Default | Description |
Return | Parameter newName. If newName == 0, a static char* with the result is returned. | ||
prefix | String oder char* | - | Prefix for the new name "" : newName is given the name that would also be used when creating a layer manually |
newName | String oder char* | 0 | Reserved memory for the returned new layer name 0 : [since v5.0 R37080] The variable may be 0 or missing, then applies: The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values. |
useGaps | int | 1 | Method for calculating the new name. The parameter is only evaluated if prefix is not empty. Assuming your document has the layer E1 and E3, you will get the following different results depending on useGaps: 0 : E4 1 : E2 |
Show me the next free layer name.
int main () { showmessage ("%s", layer::default_name ("Ebene", 0, 0)); return 0; }
static int layer::get_visible_i(int index)
Is the given layer visible or not?
Name | Type | Default | Description |
Return | int | 1 : visible 0 : hidden |
|
index | int | - | 0-based layer index. 0 is the bottommost layer. -2 : Current layer ≥ layer::count : Topmost layer |
Is the current layer visible?
int main ()
{
showmessage ("%d", layer::get_visible_i (-2));
return 0;
}
static int layer::get_visible(char* name)
Is the given layer visible or not?
Name | Type | Default | Description |
Return | int | 1 : visible 0 : hidden |
|
name | String or char* | - | Name of the layer |
static int layer::get_lock_i(int index)
Is the given layer locked or not?
Name | Type | Default | Description |
Return | int | 1 : locked 0 : unlocked |
|
index | int | - | 0-based layer index. 0 is the bottommost layer. -2 : Current layer ≥ layer::count : Topmost layer |
static int layer::get_lock(char* name)
Is the given layer locked or not?
Name | Type | Default | Description |
Return | int | 1 : locked 0 : unlocked |
|
name | String or char* | - | name of the layer |
static int layer::lock_i(int index)
Lock a index given layer.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
index | int | - | 0-based layer index. 0 is the bottommost layer. -2 : Current layer ≥ layer::count : Topmost layer |
static int layer::lock(char* name)
Lock a layer by name
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
name | String or char* | - | name of the layer |
static int layer::unlock_i(int index)
Unlock a layer by index.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
index | int | - | 0-based layer index. 0 is the bottommost layer. -2 : Current layer ≥ layer::count : Topmost layer |
static int layer::unlock(char* name)
Lock a named layer.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
name | String oder char* | - | name of the layer |
static char* layer::get_name(ItemRef frameRef)
Find out the layer name of a given document frame.
Name | Type | Default | Description |
Return | char* | Name of layer
The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values. |
|
frameRef | ItemRef | - | vValid document frame |
Show the layer of the script frame.
int main () { showmessage (layer::get_name (gFrame)); return 0; }
static int layer::get_index(ItemRef frameRef)
Find out the layer index of a given document frame. The top most layer has the index 0. In the layers panel this is the last entry.
Name | Type | Default | Description |
Return | int | 0-based level index of the given frame. 0 is the bottommost level. | |
frameRef | ItemRef | - | valid doc frame |
Show the layer index of the script frame
showmessage ("%d", layer::get_index (gFrame));
static int layer::get_printable(char* lname)
Is a given layer printable?
Name | Type | Default | Description |
Return | int | 1 : layer is printable 0 : error or not printable |
|
lname | String or char* | - | Name of the layer |
int main () { char * lname = "Ebene 2"; int state = layer::get_printable (lname); wlog ("", "%s : %d\n", lname, state); layer::set_printable (lname, !state); wlog ("", "%s : %d\n", lname, layer::get_printable (lname)); return 0; }
static int layer::set_printable(char* lnamem, int state = 1)
Set the printability of a layer.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
lname | String or char* | - | Name of the layer |
state | int | 1 | printability 0 : Layer is not printable 1 : Layer is printable |
int main () { char * lname = "Ebene 2"; int state = layer::get_printable (lname); wlog ("", "%s : %d\n", lname, state); layer::set_printable (lname, !state); wlog ("", "%s : %d\n", lname, layer::get_printable (lname)); return 0; }
static int layer::get_ui_color()
Get the name of the color of a layer of the front document. The color names are the fixed Stock colors integrated in InDesign as displayed in the 'Layer options' dialog. Custom colors are returned in the format "RGB r g b" with r, g, b ∈ [0-255].
Custom colors are not supported by comet_pdf!
The function has been implemented for internal use only. There are currently no set function yet.
Alphabetic index HTML hierarchy of classes or Java