Layers of an InDesign® document

Version :
09.11.2021, 08:27 Uhr

Layers of an InDesign® document

static int count()

How many layers does the active document have?

Name Type Default Description
Return int   Number of layers of the active document

i = layer::count ();


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static char* front_name(char* s)

Get the name of the active document layer.

For InDesign® (Desktop) this is the active layer of the current front document.

For InDesign® Server, the current front document is the last document opened and the active layer is the layer that was last defined by layer::select for this document. This specification is saved in the document and can also be defined with InDesign® (Desktop). The layer selection by normal InDesign® (Desktop) onboard tools is not sufficient for the call of front_name!

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* (Depends on parameter s)   s is returned for your convenience. Avoid calls like s = layer::front_name (s);, they don't make sense at all.
s String or char* - reserved memory for the layer name

char	s[256]
s = layer::front_name (s);


priint:comet InDesign® Plug-Ins, comet_pdf

static int rename_all(char* prefix = 0)

Rename all layers. In this the passed prefix is used as the base of the layer name :

If the prefix is empty, the standard name for layers is used.

Name Type Default Description
Return int   0 or Error code
prefix String or char* "" Name base. If the name is empty, the default name is used for the layer ('layer').

err_code = layer::rename ([s_prefix]);


priint:comet InDesign® Plug-Ins, comet_pdf

static int sort()

Sort from layer list from top to bottom.

Name Type Default Description
Return int   0 or Error code

layer::sort ();


priint:comet InDesign® Plug-Ins, comet_pdf

static int index(char* n)

At which position is the layer at? Positions are counted beginning at 0 from the last layer. If a layer is not found, -1 is returned.

Name Type Default Description
Return int   Layer position or -1.
n String or char* - Layer name

i = layer::index (s);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static char* name(int index, char* res)

Name of the i-th layer. Positions are counted beginning at 0 from the last layer. If there is no layer with the specified index, then - of course - the empty string will be returned.

Name Type Default Description
Return String or char* (Depends on parameter result)   Name of the i-th layer, same as parameter res.
index int - Layer number  
res String or char* - Reserved memory for the layer name

char s[256];
s = layer::name (i, s);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int select_i(int index)

Activate a layer specified in your 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 this case.

Name Type Default Description
Return int   0 or Error code
index int - 0-based layer index. 0 is the uppermost layer.

err_code = layer::select_i (i);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::select

static int 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.

Name Type Default Description
Return int   0 or Error code
lname String or char* - Name of a layer

err_code = layer::select (nam);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::select_i

static int set_visible_i(int index, int vis)

Display or hide a layer specified in your index.

Name Type Default Description
Return int   0 or Error code
index int - 0-based layer index. 0 is the uppermost layer.
vis int - != 0 visible, 0 hide

err_code = layer::set_visible_i (index, nam);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::set_visible

static int set_visible(char* nam, int vis)

ZDisplay or hide a layer specified by name.

Name Type Default Description
Return int   0 or Error code
nam String or char* - Name of a layer
vis int - != 0 visible, 0 hide

err_code = layer::set_visible (nam);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::set_visible_i

static int remove_i(int index)

Delete a layer specified in your index. By deleting a layer, all the objects located on this layer will be deleted.

Name Type Default Description
Return int   0 or Error code
index int - 0-based layer index. 0 is the uppermost layer.

layer::remove_i (ix);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::remove

static int remove(char* nname)

Delete a layer specified by name. By deleting a layer, all the objects on this layer will be deleted.

Name Type Default Description
Return int   0 or Error code
nname String or char* - Name of a level

layer::remove (str);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::remove_i

static int merge(char* from, char* to)

Copy the contents of the layer from in the layer to. Afterwards, the layer from will be deleted. If the content of the layer from is to be preserved, please use the function layer::copy.

Name Type Default Description
Return int   0 or Error code
from String or char* - Name of the layer the objects of which are to be moved
to String or char* - Name of the target layer

err_code = layer::merge (from, to);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::merge_ni
layer::merge_ii
layer::merge_in

static int merge_ni(char* from, int to)

Copy the contents of the layer from into the layer to. Afterwards, the layer from will be deleted. If the content of the layer from is to be preserved, please use the function layer:::copy_ni.

Name Type Default Description
Return int   0 or Error code
from String oder char* - Name of the layer the objects of which are to be moved
to int - Index of the target layer

err_code = layer::merge_ni (from, to);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::merge
layer::merge_ii
layer::merge_in

static int merge_ii(int from, int to)

Copy the contents of the layer from into the layer to. Afterwards, the layer from will be deleted. If the content of the layer from is to be preserved, please use the function layer::copy_ii.

Name Type Default Description
Return int   0 or Error code
from int - Index of the layer the objects of which are to be moved
to int - Index of the target layer

err_code = layer::merge_ii (from, to);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::merge
layer::merge_ni
layer::merge_in

static int merge_in(int from, char* to)

Copy the contents of the layer from into the layer to. Afterwards, the layer from will be deleted. If the content of the layer from is to be preserved, please use the function layer::copy_in.

Name Type Default Description
Return int   0 or Error code
from int - Index of the layer the objects of which are to be moved
to String or char* - Name of the target layer

err_code = layer::merge_in (from, to);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::merge
layer::merge_ii
layer::merge_in

static int copy(
  char* from,
  char* to,
  int exhaustive = 0,
  int reconstruct = 0,
  int completeProducts = 0)

Copy the contents of the layer from into the layer to.

Name Type Default Description
Return int   0 or Error code
from String or char* - Index of the layer the objects of which are to be moved
to String or char* - Name of the target layer
exhaustive int 0 Due to ab bug in InDesign® Server CS6 the Server may crash while executing this command. Set exhaustive to 1 to avoid this error - we use a by pass 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 page items beloning to a Comet group and NOT laying on the layer from, duplicate this page items too.

0 : no
1 : yes

Duplicate the current front layer and recreate all Comet groups.

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; }

Parameter exhaustive since v3.3.1 R3996, 2. Jul 2013
Parameter reconstruct since v3.4 R7203, 12.12.2014
Parameter completeProducts since v4.0.4 R7412, 04.Feb 2015

priint:comet InDesign® Plug-Ins, comet_pdf

layer::copy_ni
layer::copy_ii
layer::copy_in

static int copy_ni(
  char* from,
  int to,
  int exhaustive = 0,
  int reconstruct = 0,
  int completeProducts = 0)

Copy the contents of the layer from into the layer to.

Name Type Default Description
Return int   0 or Error code
from String or char* - Index of the layer the objects of which are to be moved
to int - Name of the target layer
exhaustive int 0 Due to ab bug in InDesign® Server CS6 the Server may crash while executing this command. Set exhaustive to 1 to avoid this error - we use a by pass 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 page items beloning to a Comet group and NOT laying on the layer from, duplicate this page items too.

0 : no
1 : yes

Parameter exhaustive since v3.3.1 R3996, 2. Jul 2013
Parameter reconstruct since v3.4 R7203, 12.12.2014
Parameter completeProducts since v4.0.4 R7412, 04.Feb 2015

priint:comet InDesign® Plug-Ins, comet_pdf

layer::copy
layer::copy_ii
layer::copy_in

static int copy_ii(
  int from,
  int to,
  int exhaustive = 0,
  int reconstruct = 0,
  int completeProducts = 0)

Copy the contents of the layer from into the layer to.

Name Type Default Description
Return int   0 or Error code
from int - Index of the layer the objects of which are to be moved
to int - Index of the target layer
exhaustive int 0 Due to ab bug in InDesign® Server CS6 the Server may crash while executing this command. Set exhaustive to 1 to avoid this error - we use a by pass 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 page items beloning to a Comet group and NOT laying on the layer from, duplicate this page items too.

0 : no
1 : yes

Parameter exhaustive since v3.3.1 R3996, 2. Jul 2013
Parameter reconstruct since v3.4 R7203, 12.12.2014
Parameter completeProducts since v4.0.4 R7412, 04.Feb 2015

priint:comet InDesign® Plug-Ins, comet_pdf

layer::copy
layer::copy_ni
layer::copy_in

static int copy_in(
  int from,
  char* to,
  int exhaustive = 0,
  int reconstruct = 0,
  int completeProducts = 0)

Copy the contents of the layer from into the layer to.

Name Type Default Description
Return int   0 or Error code
from int - Index of the layer the objects of which are to be moved
to String or char* - Name of the target layer
exhaustive int 0 Due to ab bug in InDesign® Server CS6 the Server may crash while executing this command. Set exhaustive to 1 to avoid this error - we use a by pass 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 page items beloning to a Comet group and NOT laying on the layer from, duplicate this page items too.

0 : no
1 : yes

Parameter exhaustive since v3.3.1 R3996, 2. Jul 2013
Parameter reconstruct since v3.4 R7203, 12.12.2014
Parameter completeProducts since v4.0.4 R7412, 04.Feb 2015

priint:comet InDesign® Plug-Ins, comet_pdf

layer::copy
layer::copy_ii
layer::copy_in

static int move(char* mv, char* before)

Change the sequence of the layer. The layer mv is moved behind the layer before.

Name Type Default Description
Return int   0 or Error code
mv char* - Name of the layer which is to be moved
before char* - Name of the layer to move the layer behind. If a layer with given name not exists, the layer will become the new front layer.

err_code = layer::move (mv, before);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::move_ni
layer::move_ii
layer::move_in

static int move_ni(char* mv, int before)

Change the sequence of the layer. The layer mv is moved in behinde the layer before.

Name Type Default Description
Return int   0 or Error code
mv String or char* - Name of the layer which is to be moved
before int - Index of the layer to move the layer behind

-1 or > number of layers : The layer will become the new front layer

err_code = layer::move (mv, before);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::move
layer::move_ii
layer::move_in

static int move_ii(int mv, int before)

Change the sequence of the layer. The layer mv is moved behinde the layer before.

Name Type Default Description
Return int   0 or Error code
mv int - Name of the layer which is to be moved
before int - Index of the layer to move the layer behind

-1 or > number of layers : The layer will become the new front layer

err_code = layer::move (mv, before);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::move
layer::move_ni
layer::move_in

static int move_in(int mv, char* before)

Change the sequence of the layer. The layer mv is moved behinde the layer before.

Name Type Default Description
Return int   0 or Error code
mv int - Index of the layer which is to be moved
before String or char* - Name of the layer to move the layer behind. If a layer with given name not exists, the layer will become the new front layer.

err_code = layer::move (mv, before);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::move
layer::move_ii
layer::move_in

static int rename(char* oldName, char* newName)

Change the name of a layer.

Name Type Default Description
Return int   0 or Error code
oldName String or char* - Name of the layer the name of which is to be changed
newName String or char* - New layer name

err_code = layer::rename (oldName, newName);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::rename_i

static int rename_i(int index, char* newName)

Change the name of a layer

Name Type Default Description
Return int   0 or Error code
index int - Index of the layer the name of which is to be changed
newName String or char* - New layer name

err_code = layer::rename_i (ix, newName);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::rename

static int rename_prefixed(char* oldName, char* prefix)

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 Error code
oldName String or char* - Name of the layer the name of which is to be changed
prefix String or char* - Prefix of the new layer name

err_code = layer::rename_prefixed (oldName, prefix);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::rename_prefixed_1

static int rename_prefixed_i(int index, char* prefix)

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 Error code
index int - Index of the layer the name of which is to be changed
prefix String or char* - Prefix of the new layer name

err_code = layer::rename_prefixed_i (index, prefix);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::rename_prefixed

static int add(
  char* newName,
  char* before,
  int doSelect = 1)

Create a new layer with the specified name at the specified position. If a layer with the specified name already exists, no additional layers can be added and the layer position remains unchanged. If the layer before is not found, the new layer will be added as the bottom-most layer. If no name is specified, a new default name will be ascertained.

A newly added layer can optionally be selected.

Name Type Default Description
Return int   0 or Error code
newName String or char* - Name of the new layer
before String or char* - Name of the layer to move the layer behind.
doSelect int 1 If the layer is to be activated immediately, yes = 1, no = 0

layer::add	 (new:name, before [, doSelect]);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::add_i

static int add_i(
  char* newName,
  int index,
  int doSelect = 1)

Create a new layer with the specified name at the specified position. If a layer with the specified name already exists, no additional layers can be added and the layer position remains unchanged. If the layer before is not found, the new layer will be added as the bottom-most layer. If no name is specified, a new default name will be ascertained.

A newly added layer can optionally be selected.

Name Type Default Description
Return int   0 or Error code
newName String or char* - Name of the new layer
before int - Name of the background layer of the new layer
doSelect int 1 If the layer is to be activated immediately, yes = 1, no = 0

layer::add_i	 (newName, before [, doSelect]);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

layer::add

static int add_prefixed(
  char* prefix,
  char*,
  int = 1)

Create a new layer with the specified name at the specified position. If a layer with the specified name already exists, a new layer name is generated using the provided prefix. If the layer before is not found, the new layer will be added as the bottom-most layer. If no name is specified, a new default name will be ascertained.

A newly added layer can optionally be selected.

Name Type Default Description
Return int   0 or Error code
prefix String or char* - Prefix for the detemination of the layer name. As an expansion the first free number is used which is not yet in use. At 999 the method is abandoned
before String or char* - Name of the background of the new layer
doSelect int 1 If the layer is to be activated immediately, yes = 1, no = 0

layer::add_prefixed (prefix, before [, doSelect]);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::add_prefixed_i

static int add_prefixed_i(
  char* prefix,
  int,
  int = 1)

Create a new layer with the specified name at the specified position. If a layer with the specified name already exists, a new layer name is generated using the provided prefix. If the layer before is not found, the new layer will be added as the bottom-most layer. If no name is specified, a new default name will be ascertained.

A newly added layer can optionally be selected.

Name Type Default Description
Return int   0 oder Fehlercode
prefix char* - Prefix for the detemination of the layer name. As an expansion the first free number is used which is not yet in use. At 999 the method is abandoned
before int - Index of the background layer of the new layer
doSelect int 1 If the layer is to be activated immediately, yes = 1, no = 0

layer::add_prefixed_i (prefix, index [, doSelect]);


priint:comet InDesign® Plug-Ins, comet_pdf

layer::add_prefixed

static char* default_name(char* prefix, char* newName)

Ascertain the next valid default name which can be used for the new layer. If the prefix is empty, InDesign® determines the name. If a prefix is specified, a number is attached to the prefix. If the document has 999 layers, the method is abandoned.

Name Type Default Description
Return String or char* (Depends on parameter result)   Ascertained default name. Same as parameter newName.
prefix String or char* - Prefix for the determination of the layer name. As an expansion he first free number is used which is not yet in use. At 999 the method is abandoned.
newName String or char* - Reserved memory for the return

newName = layer::default_name (prefix, newName);


priint:comet InDesign® Plug-Ins, comet_pdf

static int 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 uppermost layer.

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int 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

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int 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 uppermost layer.

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int 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

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int lock_i(int index)

Lock a index given layer.

Name Type Default Description
Return int   0 or error code
index int - 0-based layer index. 0 is the uppermost layer.

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int lock(char* name)

Lock a layer by name

Name Type Default Description
Return int   0 or error code
name String or char* - name of the layer

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int unlock_i(int index)

Unlock a layer by index.

Name Type Default Description
Return int   0 or error code
index int - 0-based layer index. 0 is the uppermost layer.

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int unlock(char* name)

Lock a named layer.

Name Type Default Description
Return int   0 or error code
name String oder char* - name of the layer

Version 1.4 R310, 8. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static char* 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. Learn more about functions returning r/o char* values.

frameRef ItemRef - valid doc frame

Show the layer of the script frame

showmessage (layer::get_name (gFrame));		

Version 1.4 R339, 3. Mai 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int 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 layer index. The top most layer has the index 0. In the layers panel this is the last entry.
frameRef ItemRef - valid doc frame

Show the layer index of the script frame

showmessage ("%d", layer::get_index (gFrame));		

Version 1.4 R339, 3. Mai 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int 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;
}

Version 3.1 R2178, 22. Okt. 2010

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int set_printable(char* lnamem, int state = 1)

Set the printability of a layer.

Name Type Default Description
Return int   0 or error code
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;
}

Version 3.1 R2178, 22. Okt. 2010

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

static int 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.

Name Type Default Description
Return int   0 or error code
lname String or char* - Name of the layer

v4.1.6 R25778, 23. Sep 2019

priint:comet InDesign® Plug-Ins, comet_pdf

This class has no child classes.

Author
Paul Seidel
Version
09.11.2021, 08:27 Uhr
Since
Plugin Version 1.0.8

Alphabetic index HTML hierarchy of classes or Java