Usage¶
This section gives an overview of the general usage of the priint:comet Python API
Import directives¶
Usually, Python modules are imported by providing the module or package name:
#Native libaries
import io
import csv
#Comet
import comet
These can be either native built-ins (e.g. io, csv, …), built-ins provided by our implementation (comet) or custom modules which are data pool specific.
Imports work like CScript #include statements. The CScript interpreter uses a custom callback for processing an #include directive. We are therefore able to implement custom syntax extensions using tokens to fetch an include from a specific data source. These data sources include the current XML-Offline folder, the current Pubserver or SOAP connection or the current SQL connection:
#include "internal/text.h"
#include "[xml]/actions/10000.crpt"
#include "[soap]/actions/10000.crpt"
#include "[sql]/select stmt from actions where id = 10000"
For Python we want to use the language’s default import system where possible – expanding on that would mean changing the language definition, which we avoid. The default import system however is limited to very specific inputs:
Limited to alphanumeric characters
No [xml], [sql], [Pubserver] custom directives to fetch data from the current data connection
No relative or absolute paths
The user can work around paths with executing a more verbose import:
import importlib.util
spec = importlib.util.spec_from_file_location("module.name", "/path/to/file.py")
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
foo.MyClass()
This however does not solve the problem with our data pool related tokens. Since Python exposes the importer module itself and can execute it at runtime, we can provide custom functionality for importing modules from special paths:
This function is a simple wrapper to the import module which accepts, parses and provides necessary preparation for importing modules from said data pools. The result of the function is the imported module:
myModule = comet.pyImport('[xml]/modules/myModule.py')
myModule.helloWorld()
The following datapool specific imports are supported:
Syntax |
Description |
Comments |
Example |
---|---|---|---|
XML files |
|||
[xml]/pID sID
<xml>/pID sID
.xml_/pID sID
[xml]/pID sName
<xml>/pID sName
xml_/pID sName
|
Import via the XML file panelstatements.xml. First, the panel statement will be loaded with the ID pID. The found command will then be executed. The first result column of this command must be a string. In the where-condition of the command must contain exactly one ‘?’, this ‘?’ will be replaced by sID or sName. The name may be enclosed with quotation marks but this is not necessary. The string that is found is the result of the Includes. |
Include will only be executed where there is a valid XML data link. |
comet.pyImport(‘.xml_/123, 4’) with Panel statement 123 “includes.xml” select stmt node includes.include where id = ? Result of the Includes is stmt from includes.xml with the ID 4. |
[xml]/path
<xml>/path
.xml_/path
|
Import the coded script file from the XML data folder. The path is specified relative the XML data folder. |
comet.pyImport(‘.xml_/actions/1000.crpt’) |
|
Database |
|||
[sql]/statement
<sql>/statement
.sql_/statement
|
Import from a database. |
Include will only be executed where there is a valid database connection. The first result row of the statement must be a string or CLOB. |
comet.pyImport(‘.sql_/select stmt from includes where id = 12’) |
SOAP |
|||
[soap]/id
<soap>/id
.soap_/id
|
Import from a SOAP connection. |
Include will only be executed where there is a valid SOAP connection. |
comet.pyImport(‘.soap_/mystuff.py)’ |
Pubserver |
|||
[pubserver]/LibraryIdentifier.h |
Import of a script library |
Include is only available when connected to a PubServer |
comet.pyImport(’[pubserver]/ProjectLib.h)’ |
[pubserver]/plugin/PluginName.py |
Import of Python-Code for calling Java methods of a PubServer Plugin directly from the Python. PluginName is the registration name of the Java Plugin. |
Include is only available when connected to a PubServer Take care to use the extension .pyhere. |
comet.pyImport(’[pubserver]/plugins.py)’ |
[pubserver]/plugins.c |
Import of cScript-Code for calling Java methods of all available PubServer Plugins. Please note: plugins.c is just a meta include, which contains include directives for all available Java plug-ins. |
comet.pyImport(’[pubserver]/stdlib.c)’ |
Function variables¶
Function variables follow the same syntax as in other script languages and statements. Unlike in CScript, the function variable syntax is a Python comment and the definition is thefore not removed during script execution, resulting in line numbers still being consistent when error messages come up.
There are two possible ways to access function variables in your Python scripts. Suppose you have the following function variable definition:
#pragma var "gTextColor//Text Color" "kBlack//Black" "kRed//Red" "kOrange//Orange"
Access as member of the comet module:
Any function variable is added as a direct member to the comet
module itself by name.
Access using the global function variable list of the comet module:
Additionally, the comet
module keeps a dictionary of function variables and their values.
Keys and values are always of type str
Note that function variable names may clash with built-in constants, modules or functions. In this case your script will fail to run. It is generally a good idea to prefix you function variable names with a unique, non-clashing identifier.
Placeholder synchronization¶
The module allows setting a ‘new value’ and an ‘old value’, which are only evaluated during synchronization calls.
Whether or not the script is run in a synchronization call be determined using comet.getContext()
which then returns comet.constants.kContextPlaceHolderSync
if that is the case.
The new value of a placeholder is the data source value which is determined for the automatic synchronization state of a placeholder (sync action ID = -1) and the value which is displayed in the ‘ToDo’ panel. Note that no changes may be made to the document when the script is executed as a synchronization call.
In particular, no text may be changed through functions like CFrame.replace()
and the like , since here the load scripts can be called again automatically - which can lead to endless loops.
The old value is the document value which is displayed in the document value display of the ‘ToDo’ panel. Normally this value is determined by comet automatically by extracting the value directly from the document. In certain rare cases it may be necessary to provide a different value here.
Both new and old values can be set by calling comet.setOutput()
with the keys ‘gNewValue’ or ‘gOldValue’, respectively.
See here for more information: kContextPlaceHolderSync
Repeating Elements¶
When building repeating elements there is a number of output variables which need to be filled during the build action of the placeholder.
Variable Name
Data type
Description
gElements
List of products to build
gFormat
Format string
The same build action can be used for synchronization purposes for repeating elements. In this case the variables in the lower table can be filled to customize the synchronization behavior.
Variable Name
Data type
Description
gPrivateSync
Set the value to True, to enable your customized sync. Otherwise the default behavior is executed.
gState
The result state of the repeating element. Default is 1 (Okay)
gSyncChanged
When manually setting the sync state, set this variable to True
gOldValue
The string is shown in the ToDo panel as the Document text.
gNewValue
The string is shown in the ToDo panel as the Data pool text.
Calling other scripts¶
It is possible to call other script types from Python.
For this purpose there are two script functions available: comet.runJavaScript()
and comet.runCScript()
The possibility on calling these depends on the host software:
InDesign® JavaScript, CScript
comet_pdf® Illustrator® CScript
CScript¶
CScript calls can be made using the function comet.runCScript()
.
This function provides automatic environment variable conversion - environment variables from comet which are available in
the executing Python script are also available in the CScript.
Which variables are available and get converted depend on the execution context and are listed in the section Environment variables.
Only input variables are automatically converted.
Function variables are a special case since they provide the variable key and value as global variables,
aswell as both gFuncVarNames and gFuncVarValues of type StringList.
Additionally, it is possible to provide custom variables - using the items parameter - so you can easily access your Python data in CScript.
The following table shows which types are supported and which result type to expect.
Python ➞ CScript¶
Source data type
Target data type
Availability
int
InDesign® comet_pdf® Illustrator®
float
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
InDesign® comet_pdf® Illustrator®
All other variable types are ignored and not automatically converted.
JavaScript¶
When calling JavaScript from Python you may want to provide additional, non-primitive environment variables
to your script. comet.runJavaScript()
has an additional parameter called items which can be used
to provide a list of certain Python objects which are then additionally available in the executed script.
For each object which belongs to a document, two environment variables are created:
gItemRefN and gDocRefN where N is the nth object in the list, starting at 1.
e.g. when a list of three CFrame
objects is provided to the items parameter you get six global variables of
type ItemRef in your CScript:
gItemRef1, gItemRef2, gItemRef3, gDocRef1, gDocRef2, gDocRef3
When the provided object in items has no document, the creation of the gDocRefN parameter is omitted,
but the N suffix is still increased so that when e.g. gItemRef1 has no gDocRef equivalent,
gDocRef2 is the next candidate for the next document variable name.
Vice versa, when a provided object in items is a document itself, only the next gDocRef variable is created,
and the gItemRef variable is omitted.
The following table shows all allowed types for entries in the items list:
Python ➞ JavaScript¶
Source data type
Target data type
Creates gItemRefN
Creates gDocRefN
PageItem
✓
✓
Document
✗
✓
Table
✓
✓
Environment variables¶
Comet provides a contingent of environment variables for your scripts to provide easy access
to commonly used data, or data which is only available in certain situations.
The availability of the environment variables highly depends on the situation a Python script is
executed in. e.g. an environment variable specifying a text model can not be available in a script
reacting to the checkout of a publication.
All environment variables are prefixed with the letter g.
The tables below provide an exhaustive list of all environment variables per context.
The script context type can be determined by calling comet.getContext()
and comparing the result
to the context constants provided by the comet module: Contexts
Environment variables are seperated into two categories:
Input variables and output variables.
Input variables¶
Input variables provide context data for the currently executing script.
They are available as members of the comet
module.
However, they are not documented as members of the module since they are not universally available.
e.g. the input variable comet.gFrame in the context kContextPlaceHolderLoad is an instance of CFrame
and represents the frame of the placeholder which is currently being loaded.
All input environment variables are read-only. Assigning them new values is undefined behavior and can lead to crashes and errors.
Output variables¶
Output variables are used for providing callback data to comet to drive comet’s behavior after executing a script in the current context.
e.g. the output variable gTableID in the context kContextPlaceHolderLoad in a table placeholder can be set to determine which table template should be loaded.
For this purpose the comet.setOutput()
must be used to set the output variables in the active context.
The provided value type must match the type required by the context and variable name according to the tables provided on a per context basis below.
Variables by context¶
kContextAfterLogin¶
Input variables¶
Variable
Data type
Description
gLogins
Count of successful logins since last start
kContextAllowLogin¶
Input variables¶
Variable
Data type
Description
gLogins
Count of successful logins since last start
gDBC
None
NOT IMPLEMENTED
kContextBeforeLogout¶
No environment variables
kContextBatch¶
Input variables¶
Variable
Data type
Description
gObjectPath
File path of the input file before moving it to the XCache.
This file does not exist anymore at this point,
because it has already been moved to the XCache!
gInFile
File path of the input file in the XCache.
This is the current file you are working on!
gSourcefolder
The designated input folder
gDestfolder
The designated output folder
kContextCometTestPreScript¶
No environment variables.
kContextCometTestScript¶
Same as kContextCometTestPreScript
kContextCometTestPostScript¶
Same as kContextCometTestPreScript
kContextDocWatch¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gDocumentPath
The complete local path to the document
gDocumentPathPDF
The complete local path to the document, but with the extension pdf
gBeforeMetaData
Set to true when called before document close directly before creating the metadata
kContextExtendScript¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gFrame
The first selected frame
kContextPanelAction¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gRun
Determines the selection context this panel action is run in
gRun
Selection
Description
1 … n
At least one frame is selected.
At least one frame is selected. gRun contains the frame number
0
Nothing selected
Neither a frame not text is selected
-1
Text selected
Text tool is active and text cursor is set
gFrame
When gRun is is not 0, this is the active frame.
gTextModel
When gRun is is not 0, this is the active text model.
gStart
When gRun is -1, this is the start index of the selected text
gLen
When gRun is -1, this is the length of the selected text
kContextPlaceHolderLoad¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the placeholder
gTextModel
Active textmodel of the placeholder
gPlaceholderID
ID of the placeholder
gStart
Start index of the text placeholder
gLen
Length of the text placeholder
gLink
For frame placeholders of the complete path on the image which is displayed in the frame. Otherwise the string is empty.
gLinkFolder
For frame placeholders of the path on the image, which is displayed in the frame. The path contains no path delimiter at the end. Otherwise the string is empty.
gLinkName
For frame placeholders of the name of the image, which are displayed in the frame. Otherwise the string is empty.
gCreated
Placeholders creation date and time, format YYYYMMDDHHMMSS.
gModified
Last time the placeholder was loaded, format YYYYMMDDHHMMSS.
gFuncVars
Function variables as key-value pairs. See Function variables
gRecordID
ID of the data record
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
Output variables¶
Variable
Data type
Description
gTableID
Table template ID
which replaces the current text of the place holder
Only available for table placeholder load actions
gBuildTable
Normally tables are build automatically after insertion
into the document. If you wish to suppress this behavior,
set gBuildTable to False
Only available for table placeholder load actions
gExportValue
If the option
Behavior when loading placeholders ->
Load and export to update folder
is activated, placeholder contents are saved in the current
update folder. For placeholders with a load script,
the content of the variable gExportValue is used.
gSyncChanged
The placeholder state is set to Okay after successful load
scripts automatically.
In case you changed the placeholder state inside the script yourself,
you can suppress this behavior by setting gSyncChanged to True
kContextPlaceHolderSync¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the placeholder
gTextModel
Active textmodel of the placeholder
gPlaceholderID
ID of the placeholder
gStart
Start index of the text placeholder
gLen
Length of the text placeholder
gLink
For frame placeholders of the complete path on the image which is displayed in the frame. Otherwise the string is empty.
gLinkFolder
For frame placeholders of the path on the image, which is displayed in the frame. The path contains no path delimiter at the end. Otherwise the string is empty.
gLinkName
For frame placeholders of the name of the image, which are displayed in the frame. Otherwise the string is empty.
gCreated
Placeholders creation date and time, format YYYYMMDDHHMMSS.
gModified
Last time the placeholder was loaded, format YYYYMMDDHHMMSS.
gFuncVars
Function variables as key-value pairs. See Function variables
gRecordID
ID of the data record
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
Output variables¶
Variable
Data type
Description
gNewValue
The ‘new value’ used for synchronization purposes and the
data source value in the ToDoList panel
Only available when using autosync
(Use load action as sync action)
gOldValue
The ‘old value’ used for synchronization purposes and the
document value in the ToDoList panel.
This value is usually automatically calculated and only needs
to be set in rare circumstances
Only available when using autosync
(Use load action as sync action)
gSyncChanged
The placeholder state is set to Okay after successful load
scripts automatically.
In case you changed the placeholder state inside the script yourself,
you can suppress this behavior by setting gSyncChanged to True
kContextPlaceHolderStringCompare¶
kContextPlaceHolderStringCompare
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the placeholder
gTextModel
Active textmodel of the placeholder
gPlaceholderID
ID of the placeholder
gStart
Start index of the text placeholder
gLen
Length of the text placeholder
gDocumentValue
The text from the document
gDataPoolValue
The text from the data source
gRecordID
ID of the data record
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
kContextPlaceHolderStore¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the placeholder
gTextModel
Active textmodel of the placeholder
gPlaceholderID
ID of the placeholder
gStart
Start index of the text placeholder
gLen
Length of the text placeholder
gLink
For frame placeholders of the complete path on the image which is displayed in the frame. Otherwise the string is empty.
gLinkFolder
For frame placeholders of the path on the image, which is displayed in the frame. The path contains no path delimiter at the end. Otherwise the string is empty.
gLinkName
For frame placeholders of the name of the image, which are displayed in the frame. Otherwise the string is empty.
gCreated
Placeholders creation date and time, format YYYYMMDDHHMMSS.
gModified
Last time the placeholder was loaded, format YYYYMMDDHHMMSS.
gFuncVars
Function variables as key-value pairs. See Function variables
gRecordID
ID of the data record
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
kContextPlaceHolderBuild¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gPlaceholderID
ID of the placeholder
gStart
Start index of the text placeholder
gLen
Length of the text placeholder
gFrame
Active frame of the placeholder
gLink
For frame placeholders of the complete path on the image which is displayed in the frame. Otherwise the string is empty.
gLinkFolder
For frame placeholders of the path on the image, which is displayed in the frame. The path contains no path delimiter at the end. Otherwise the string is empty.
gLinkName
For frame placeholders of the name of the image, which are displayed in the frame. Otherwise the string is empty.
gCreated
Placeholders creation date and time, format YYYYMMDDHHMMSS.
gModified
Last time the placeholder was loaded, format YYYYMMDDHHMMSS.
gFuncVars
Function variables as key-value pairs. See Function variables
gRecordID
ID of the data record
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
Output variables¶
Variable
Data type
Description
gElements
List of elements to establish.
gFormat
Format string
gNewValue
The string is shown as data source text when the element
is selected in the ToDo panel.
gOldValue
The string is shown as document text when the element is
selected in the ToDo panel.
gPrivateSync
Set the value to True if the sync calculation of the script
should be used. Otherwise the default calculation for
the sync status is used.
gState
Set the desired status of the repeating element here.
See Sync states
kContextPlaceHolderBuildPost¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the placeholder
gPlaceholderID
The placeholder ID
gFrames
The established frames
gRecordID
ID of the object the placeholder is linked to
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
kContextPlaceHolderPrefix¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the placeholder
gTextModel
The active text model of the placeholder
gStart
Start index of the text placeholder
gLen
Length of the text placeholder
gCreated
Placeholders creation date and time, format YYYYMMDDHHMMSS.
gModified
Last time the placeholder was loaded, format YYYYMMDDHHMMSS.
gPlaceholderID
ID of the placeholder
gPlaceholderType
Type of the placeholder
1: Text placeholder
8: Table placeholder
gDelimiterType
Type of the delimiter. Possible values:
gRecordID
ID of the object the placeholder is linked to
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
Output variables¶
Variable
Data type
Description
gNewValue
New delimiting text. May be %!TT text
kContextPlaceHolderPostfix¶
Same as kContextPlaceHolderPrefix
kContextServerInterface¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gDocumentPath
The complete local path to the document
gPublicationID
ID of the publication to be processed. Empty if no publication is to be processed.
gDestinationPath
Path for an output file. Empty if not defined for this script.
gArgument
The value of the argument parameter passed to the function call.
gPublications
List of documents which are allowed to be processed in this script.
Output variables¶
Variable
Data type
Description
gOutput
This variable stores the return value of the function.
Maximum length is 32MB (32 * 1024 * 1024 bytes).
kContextPODSpecialCases¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gParam1
gParam2
gParam3
gParam4
Parameters 1-4 as str
gParamInt1
gParamInt2
gParamInt3
gParamInt4
Parameters 1-4 as int or 0 if the str is not
convertible to an int
gParamFloat1
gParamFloat2
gParamFloat3
gParamFloat4
Parameters 1-4 as float or 0.0 if the str is not
convertible to a float
kContextDoubleClickPreviews¶
Input variables¶
Variable
Data type
Description
gClicked
Row index of the double clicked entry
gDocumentPath
The complete local path to the document
gDocumentStatus
The document state on the server
gDocument
The current document
gDocumentID
Document ID of the current document
gMasterDoc
Master document
gRecordID
ID of the document
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
kContextDoubleClickProductPool¶
kContextDoubleClickProductPool
Input variables¶
Variable
Data type
Description
gClicked
Row index of the double clicked entry
gRecordID
ID of the product
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
kContextDoubleClickPublications¶
kContextDoubleClickPublications
Input variables¶
Variable
Data type
Description
gClicked
Row index of the double clicked entry
gDocumentPath
The complete local path to the document
gDocumentStatus
The document state on the server
gDocument
The current document
gDocumentID
Document ID of the current document
gMasterDoc
Master document
gRecordID
ID of the document
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
Output variables¶
Variable
Data type
Description
gDocumentPath
When this value is changed (should only be done in Panelstatement 111: Checkout), the value is used for the list entry.
gDocumentStatus
When this value is changed (should only be done in Panelstatement 114: Status), the value is used for the list entry.
kContextBuildSupport¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gSituation
Current calling situation.
kSituationCheckSizeBefore
:
Checking the size of the template against the page
element size was successful. Commit?
return 0 : Yes
return 1 : No. The build process will jump to the
next matching page element.
gFrames and gPreviousFrames
are empty in this situation.
kSituationProductPlaced
:
The product is loaded, built and placed now.
You may implement fine tuning here.
When the product is enlarged, some frames of the product
may be moved to another page element by the build process.
The return value of the function is ignored.
kSituationCheckSizeAfter
:
Checking the size of the imported and loaded product frames
against the page element was successful. Commit?
return 0 : Yes
return 1 : No. The build process will jump to the next
matching page element.
gFrames contains the inserted frame.
gPreviousFrames is empty.
kSituationBeforeCreateContinue
:
At least one inserted frame can be continued.
The frames have received their final position and size
Now the next continuation is to be created
gFrames contains the frames to be continued.
gPreviousFrames is empty
kSituationAfterCreateContinue
:
A continuation template has been successfully inserted,
loaded, and positioned.
The frames have received their final position and size.
gFrames contains all the frames of the continuation.
gPreviousFrames contains the frames of the predecessor.
The return value of the function is ignored.
kSituationAfterBuild
:
The product is now fully built and positioned.
gFrames contains all frames
including all continuations of the product.
The return value of the function is ignored
Attention: You can still insert new frames into the
document here.
These frames get an internal marking which causes them to
be deleted automatically before reorganizations.
This way it is not necessary to delete them during
kSituationCheckSizeBefore
kSituationUnsolvableOversets
:
The product build checks whether oversets can
be resolved using continuations.
If after two new pages of continuations the overset
has not changed, the process is cancelled.
At the end of each product that contains such unresolvable
text chains, this situation is executed.
gFrames contains the first frame of each text chain
that cannot be resolved.
kSituationProductFinished
:
Now that the product has been fully built and positioned,
all text displacements and comet notes have been updated
and all product frames have been combined into a new
comet group.
gFrames contains all frames including all
continuations of the product.
You can add frames here that will not become part of the
comet group.
Attention: These frames are not automatically
handled by the reorganization.
gPageNum
1-based page number at which the build process is currently located.
gTemplateID
Current template resolved to page type and continuation
gTemplateName
gPageTemplateID
Current page template resolved to page type
gPageTemplateName
gElement
1-based element and element name
gElementName
gGridPosX
Current position relative to the 1:N element
gGridPosY
gElementLeft
Page relative coordinates of the current page element
gElementTop
gElementRight
gElementBottom
gFrames
List of frames as described in gSituation
gPreviousFrames
List of frames of the predecessor subtemplate filled.
(only for continuations in case of
kSituationAfterCreateContinue
)
gProducts
Entire list of products to be built/reorganized.
gProduct
This product is being built. The object must not be changed!
Changes to the content of the object are allowed to all attributes except:
Please note that changes may no longer have any influence
on the product build process because the corresponding property has
already been evaluated.
gProductCounter
1-based counter of built products.
Page templates in the gProducts list are not counted.
To determine the index of gProduct in gProducts, use
Output variables¶
Variable
Data type
Description
gPage
The variable supports the creation of additional pages
in the build process and is only evaluated in the kSituationProductPlaced
situation.
If your build support script has created additional pages,
the value specifies the page index on which the build process is to be continued.
gNewFrames
The variable supports the creation of additional pages
in the build process and is only evaluated in the kSituationProductPlaced
situation.
If your build support script has created additional pages,
all frames that were created when new pages were created must be entered in the list.
gProductsDirect
Complete list of products to be set up/reorganized, see gProducts above.
In contrast to gProducts, changes to this list are evaluated by the product build process.
Warning
The list should be constructed from gProducts, leaving entries before gProduct unchanged
The current product can only be changed according to the rules for gProduct above
The list must not be shorter than the index of gProduct in gProducts + 1
Additionally inserted frames are re-inserted during reorganization.
To prevent this, the inserted frames must be marked appropriately
(e.g. with CPageItem.setScriptTag()
) so that the frames can be found again and either deleted or reused.
Alternatively, you can check whether additional frames can also be inserted as.
product trailers .
See below for an example.
Insert a new page template after each placed product using gProductsDirect¶
#!py
#pragma plain
import comet
def main():
#Insert a new page template after each product, so the next product starts on a new page
if comet.gSituation != comet.constants.kSituationProductPlaced:
return 0
#Create a 'page template' product entry
product = comet.product.create()
product.setAttribute(comet.constants.kProductProductType, 4) #4 is page template
product.setAttribute(comet.constants.kProductID, 1) #Page template ID
#Get the original product list and copy it
products: list[comet.CProduct] = comet.gProducts
#Determine the index where we want to insert the page template
index = products.index(comet.gProduct)
#Insert the page template...
products.insert(index + 1, product)
#... and set the new product list
comet.setOutput('gProductsDirect', products)
return 0
kContextProductBuildPre¶
Input variables¶
Variable
Data type
Description
gScriptType
The situation is which the script is called.
The following values are possible:
1: kPreScript
2: kPreRule
3: kPostRule
4: kExtraPlacement
5: kTextflowPreScript
6: kTextflowPreRule
7: kTextflowPostRule
gPage
Current 1-based page destination number (not index)
If the script creates new pages,
this is also an output variable which needs to be changed
gMasterpage
Master page name. Use this value if you are creating new pages.
gMasterpageL
gMasterpageR
Master page name for right pages in single sided documents.
gProducts
Complete list of products to build.
This is also an output variable which can be changed.
gProduct
Current product to place in the document,
only defined inside the steps kPreRule and kPostRule.
Output variables¶
Variable
Data type
Description
gPage
Current 1-based page destination number (not index)
If the script creates new pages,
this needs to be updated
gProducts
Complete list of products to build.
kContextFuncVarAvailValues¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
The frame of the placeholder
gVariableName
Name of the function variable used in the script
gVariableDisplayName
Display name of the function variable
gPlaceholderID
ID of the placeholder
gCallingActionID
ID of the action that called this action
Output variables¶
Variable
Data type
Description
gAvailableValues
The available values for this function variable
kContextFuncVarDynamicDef¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
The frame of the placeholder
gPlaceholderID
ID of the placeholder
gCallingActionID
ID of the action that called this action
Output variables¶
Variable
Data type
Description
gFuncVars
Full list of function variables.
The values in the list are tuples of
(variable name, [variable values]), e.g.
[(‘Var2Name’, [‘Var2Value1’, ‘Var2Value2’]),
(‘Var2Name’, [‘Var2Value1’, ‘Var2Value2’])]
kContextLayoutRule¶
kContextLayoutRule
and kContextLayoutRuleCondition
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the layout rule
gRecordID
ID of the object the placeholder is linked to
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
gPlaceholderID
The placeholder ID or 0 if not linked
gLink
For frame placeholders of the complete path on the image which is displayed in the frame.
Otherwise the string is empty.
gLinkFolder
For frame placeholders of the path on the image, which is displayed in the frame.
The path contains no path delimiter at the end. Otherwise the string is empty.
gLinkName
For frame placeholders of the name of the image, which are displayed in the frame.
Otherwise the string is empty.
gCreated
Placeholders creation date and time, format YYYYMMDDHHMMSS.
gModified
Last time the placeholder was loaded, format YYYYMMDDHHMMSS.
gWhen
Situation the script is executed in. See Layout rule situations
gParam1 … gParamN
Parameters of the layout rule
gFrameLeftBefore
Coordinates of the frame before executing the rule
gFrameTopBefore
gFrameRightBefore
gFrameBottomBefore
gOrgFrameLeft
Original coordinates (in points) of the frame when the rule was set.
The coordinates are updated with every change to a rule or
condition of the frame within the frame.
gOrgFrameTop
gOrgFrameRight
gOrgFrameBottom
gFrames
Only in calls to “after load” or “after build” rules.
After loading, the list also contains the frames that should be loaded now
(e.g. the frames in the current document selection you’re loading)
After building, the list contains the frames of the inserted template.
gSender
In a rule with the condition “Handle Event” the variable contains the frame reference to
the calling frame. Otherwise the reference is empty
gKey
In the rule under the condition “Handle Event” the variable contains the key
assigned by the sender.
gSenderData1
In an event sender two more values can be specified in addition to the key.
Those parameters are passed into the variables in the handling rule and can be used there.
gSenderData2
gIsInBuild
In which context was the rule called?
1 : Page build, Grid build, Text flow build, Clean up or reorganization
0 : otherwise
gCurrentPageTemplate
If gIsInBuild == 1, the globals containing the ID of the currently used page template
and (1-based) sequence number of the current page element.
gCurrentSeq
kContextLayoutRuleCondition¶
Same as kContextLayoutRule
kContextLayoutRuleDynamicList¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
Active frame of the layout rule
gRuleID
ID of the calling rule
gRuleName
Name of the calling rule
Output variables¶
Variable
Data type
Description
gValues
The values to display in the list. These values are not translated.
gDefaultEntry
Index of the default entry in the list.
Bear in mind that the first two entries (“Empty” and the separator) are counted too,
and that the index is 0 based. Your first actual entry has the index 2
kContextProductPoolEntries¶
Input variables¶
Variable
Data type
Description
gDocument
The current document.
gDocumentID
Document ID of the current document.
gRecordID
ID of the parent product.
This and the related values below are only filled when loading
child entries of a product.
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the parent product.
gPSGroupId
Group ID of the parent product.
gPSEntityId
Identifier of the parent product’s entity.
gPSEntityClass
Class of the parent product’s entity.
gPSParentRecordId
ID of the parent’s product’s parent.
gPSParentGroupId
Group ID of the parent’s product’s parent.
gPSParentEntityId
Identifier of the parent’s products’ entity.
gPSParentEntityClass
Class of the parent’s product’s entity
gLevel
Nesting depth of the parent product in the tree hierarchy.
gIconID
The icon ID of the parent product.
gDefaultTemplateID
The default template ID in the product pool.
gDefaultTemplateName
The default template name in the product pool.
Output variables¶
Variable
Data type
Description
gProducts
Resulting products to display in the product pool.
kContextProductPoolSFDefaultValue¶
kContextProductPoolSFDefaultValue
See here for additional information.
Output variables¶
Variable
Data type
Description
gStatementID
ID of the find statement or 0 when using default search
gFieldNum
Number of the search field (1-4)
Output variables¶
Variable
Data type
Description
gValues
String for the result
kContextPublicationCheckout¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gDocumentPath
The complete local path to the document
gDocumentStatus
The document state on the server
Output variables¶
Variable
Data type
Description
gDocumentPath
When this value is changed (should only be done in Panelstatement 111: Checkout), the value is used for the list entry.
gDocumentStatus
When this value is changed (should only be done in Panelstatement 114: Status), the value is used for the list entry.
kContextPublicationAfterSave¶
Same as kContextPublicationCheckout
kContextPublicationBeforeClose¶
kContextPublicationBeforeClose
Same as kContextPublicationCheckout
kContextPublicationStatus¶
Same as kContextPublicationCheckout
kContextPublicationCheckin¶
Same as kContextPublicationCheckout
kContextPublicationAfterClose¶
Same as kContextPublicationCheckout
kContextPublicationRevert¶
Same as kContextPublicationCheckout
kContextPublicationAfterCheckout¶
kContextPublicationAfterCheckout
Same as kContextPublicationCheckout
kContextCanDeleteTemplate¶
Input variables¶
Variable
Data type
Description
gRecordID
ID of the template
gRecordStringID
Name of the template
gTimestamp
Timestamp of the last change to the template.
The value provided in milliseconds and corresponds to the timestamp of the templates.
(POSIX time)
gLastUpdatedBy
Who made the last change to the template?
Output variables¶
Variable
Data type
Description
gResult
The following information is permitted in the result:
Empty str : The template may be deleted.
‘beep’ : The template may not be deleted. The deletion attempt causes a beep.
‘no_message’ : The template may not be deleted. The deletion attempt is ignored.
Otherwise : The template may not be deleted. If a deletion attempt is made, the value is displayed as a warning message.
kContextURLDropActionID¶
Input variables¶
Variable
Data type
Description
gFrame
The frame at which the URL was dropped. When the drop did not occur at a frame, the value is invalid.
gDropX
Page-relative X position of the Drop
gDropY
Page-relative Y position of the Drop
gPage
Page where the drop occured
gLayer
Layer on which the drop occured
gURL
The URL which was dropped
Output variables¶
Variable
Data type
Description
gActionID
The action to call for this drop.
Leave unchanged to not call any action
kContextURLDrop¶
Input variables¶
Variable
Data type
Description
gDropX
Page-relative X position of the Drop
gDropY
Page-relative Y position of the Drop
gPage
Page where the drop occured
gLayer
Layer on which the drop occured
gURL
The URL which was dropped
gFrame
The frame at which the URL was dropped. When the drop did not occur at a frame, the value is invalid.
kContextURLLinkDestFolder¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gURL
Complete URL of Web Image
gDestName
Local name of the image file
Output variables¶
Variable
Data type
Description
gDestFolder
Destination folder
If the string is empty, the image is placed in the default
folder relative to the document, otherwise the result must
contain a valid folder path. If the folder does not exist, it
will be created automatically, if possible.
kContextURLLinkHeaderData¶
Input variables¶
Variable
Data type
Description
gURL
Current URL
gName
Name of the header data
Output variables¶
Variable
Data type
Description
gHeaderData
Result list. Use this to store all required header data
kContextAlternativeTemplate¶
Input variables¶
Variable
Data type
Description
gPageitemName
Name of the template. empty on calls out side the build process (drag and drop, …)
gPageNum
1-based page number to insert the template at
gPage
Page object according to gPageNum
gLayerName
Name of the layer on which the template is to be inserted. This is not the current
layer, but the designated insertion layer
gLayer
Layer according to gLayerName
gPositionX
Insertion position for the template.
Caution If the page layout is within a 1:N element, the position
specifications are not always identical with the actual insertion position in the
document.
The next free grid space can only be determined after the template (and its size)
has been determined.
gPositionY
gGridPosX
Insertion position within a 1:N element relative to the element
Caution If the page layout is within a 1:N grid element, the position
specifications are not always identical with the actual insertion position in the
document.
The next free grid space can only be determined after the template (and its size)
has been determined.
gGridPosY
gElementLeft
Current page element coordinates
gElementTop
gElementRight
gElementBottom
gElement
Current page element of the build process (1-based).
Attention With 1:N elements, multiple script calls can be made with the same
element. In this case, also test the gGridPosX and gGridPosY variables.
gElementName
gPageTemplateID
Current page template of the build process.
0/empty str on calls outside of the build process (e.g. drag and drop of a product)
gPageTemplateName
gProducts
The variables contain the current product details during page build and
reorganizations. When simply inserting templates or products, they are empty.
gProduct
gProductCounter
gPageitemID
Current template ID. Also an output variable.
Output variables¶
Variable
Data type
Description
gPageitemID
Current template ID. If another template is to be used,
the value of the variable can be changed accordingly.
kContextTableModuleInsertRow¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gTable
Reference to the table that is being built.
At the time of the call the table is reset (see CTable.reset()
)
and no new rows or columns have been created yet.
gColumn
Calling cell indices
gRow
gRootTableRecordID
Root-ID of the table
gRootTableRecordID2
gRootTableRecordID3
gRootTableRecordStringID
gColumnRecordID
ID of the table column
gColumnRecordID2
gColumnRecordID3
gColumnRecordStringID
gRowRecordID
ID of the table row
gRowRecordID2
gRowRecordID3
gRowRecordStringID
gCellRecordID
ID of the table cell
gCellRecordID2
gCellRecordID3
gCellRecordStringID
gPSRootTableRecordId
ID of the data record of the table
gPSRootTableGroupId
Group ID of the data record of the table
gPSRootTableEntityId
Identifier of the entity of the table
gPSRootTableEntityClass
Class of the entity of the table
gPSRootTableParentRecordId
ID of the parent data record of the table
gPSRootTableParentGroupId
Group ID of the parent data record of the table
gPSRootTableParentEntityId
Identifier of the entity of the parent of the table
gPSRootTableParentEntityClass
KClass of the entity of the parent of the table
gPSColumnRecordId
ID of the data record of the column
gPSColumnGroupId
Group ID of the data record of the column
gPSColumnEntityId
Identifier of the entity of the column
gPSColumnEntityClass
Class of the entity of the column
gPSColumnParentRecordId
ID of the parent data record of the column
gPSColumnParentGroupId
Group ID of the parent data record of the column
gPSColumnParentEntityId
Identifier of the entity of the parent of the column
gPSColumnParentEntityClass
Class of the entity of the parent of the column
gPSRowRecordId
ID of the data record of the row
gPSRowGroupId
Group ID of the data record of the row
gPSRowEntityId
Identifier of the entity of the row
gPSRowEntityClass
Class of the entity of the row
gPSRowParentRecordId
ID of the parent data record of the row
gPSRowParentGroupId
Group ID of the parent data record of the row
gPSRowParentEntityId
Identifier of the entity of the parent of the ro
gPSRowParentEntityClass
Class of the entity of the parent of the row
gPSCellRecordId
Id of the data record of the cell
gPSCellGroupId
Group Id of the data record of the cell
gPSCellEntityId
Identifier of the entity of the cell
gPSCellEntityClass
Class of the entity of the cell
gPSCellParentRecordId
ID of the parent data record of the cell
gPSCellParentGroupId
Group ID of the parent data record of the cell
gPSCellParentEntityId
Identifier of the entity of the parent of the cell
gPSCellParentEntityClass
Class of the entity of the parent of the cell
Output variables¶
Variable
Data type
Description
gProducts
Products to build by the calling hot spot cell.
gMoreGroups
Additional groups of created cells.
Example:
Gruppe_1
Gruppe_1 master
“Gruppe 1” master
kContextTableModuleInsertColumn¶
kContextTableModuleInsertColumn
Same as kContextTableModuleInsertRow
kContextTableModuleLayoutRule¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gTable
Reference to the table that is being built.
gAreaLeft
Table area to work on (0-based)
gAreaRight is the first column outside this area.
gAreaBottom is the first row outside this area.
gAreaTop
gAreaRight
gAreaBottom
gAlternatingColumnsOn
Apply rule alternating?
gAlternatingRowsOn
gAlternatingColumnsStart
First row/column to work on on alternating rules.
gAlternatingRowsStart
gAlternatingColumnsStep
Step size for alternatings.
gAlternatingRowsStep
gGroups
Complete list of groups to work on resp. to exclude.
Strings are empty if Check groups is disabled for this the rule.
gNotInGroups
kContextTableModuleCellID¶
Same as kContextTableModuleInsertRow
kContextNoteParastyle¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
Output variables¶
Variable
Data type
Description
gParastyle
Name of the paragraph style to be used for new Comet notes.
If the value is empty or the style does not exist in the document,
the values from gFontName, gFontface and gFontsize are used.
gFontname
Font for new Comet notes. If the font is empty or the font size is 0.0,
the values are ignored and the default InDesign® font is used
for new text frames.
If the gFontface font style is empty, the Regular style is used.
gFontface
gFontsize
kContextNoteTargetLayer¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
Output variables¶
Variable
Data type
Description
gLayername
Name of the desired target layer for completed Comet notes.
For notes to be moved to this layer, the layer must exist.
kContextXMLScript¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
The current frame
kContextToDoListCustomTask¶
Input variables¶
Variable
Data type
Description
gOwnerFrame
The owning frame
gName
gComment
gDocumentToDo
gActionID
gLevel
gCometGroupID
gRecordID
ID of the data record
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
ID of the data record
gPSGroupId
Group ID of the data record
gPSEntityId
Identifier of the entity
gPSEntityClass
Class of the entity
gPSParentRecordId
ID of the parent of data record
gPSParentGroupId
Group ID of the parent data record
gPSParentEntityId
Identifier of the entity of the parent
gPSParentEntityClass
Class of the entity of the parent
gProductID
ID of the product
gProductID2
gProductID3
gProductStringID
gProductStringID1
gProductStringID2
gProductStringID3
kContextPreviewsEntries¶
Input variables¶
Variable
Data type
Description
gSearchField1
Current values of the two search fields.
Unlike PreviewStatements that execute a select statement,
the contents of the search fields are not automatically extended by ‘%’ here.
gSearchField2
Output variables¶
Variable
Data type
Description
gProducts
List of previews to be shown
gButtonState
State of the load button of the preview
0 : Invisible (for all products of the list gProducts)
1 : Inactive (for all products of the list gProducts)
2 : Visible and active (for all products of the list gProducts)
-1 : The value is defined with CProduct.setAttribute()
with kPreviewButtonState in the individual products
gLinkScript
ID of the action to be executed after insertion of the entry (text or image),
see here.
If you set this value to ≥ 0 it is used for all entries of the list gProducts.
Otherwise set the value individually with CProduct.setAttribute()
and the slot kPreviewLinkScript.
kContextPreviewsLink¶
Input variables¶
Variable
Data type
Description
gRecordID
ID of the preview entry which triggered the script.
Note that these IDs are normally no valid object IDs.
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
gPSGroupId
gPSEntityId
gPSEntityClass
gPSParentRecordId
gPSParentGroupId
gPSParentEntityId
gPSParentEntityClass
gImageAlign
Image position and scaling in the panel Previews
gSnippetStart
Current insertion position and length for text replacements.
If the contents of text placeholders are replaced by simple text entries,
these values are identical to gStart and gLen.
However, when text snippets are inserted, the placeholder is removed, gStart is then 0,
gLen is the length of the entire text.
So that you know the current text positions anyway,
there are gSnippetStart and gSnippetLen.
When snippet frames are inserted into the document (rather than as inlines in the text)
the variables have the following values:
gSnippetStart : 0
gSnippetLen : -1
gSnippetLen
kContextPageTemplateAfterApply¶
kContextPageTemplateAfterApply
Input variables¶
Variable
Data type
Description
gRecordID
ID of the preview entry which triggered the script.
Note that these IDs are normally no valid object IDs.
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
gPSGroupId
gPSEntityId
gPSEntityClass
gPSParentRecordId
gPSParentGroupId
gPSParentEntityId
gPSParentEntityClass
gProduct
Current, complete list of products to build,
including all page templates and the current product.
Changes made on the list or the product
will change the result of the build.
Only filled in calls by the product build (gScriptType = 2 or 3).
gProducts
gScriptType
1 : Page template is set manually or with page::set_info
2 : Page build
3 : Page build continuation of a product
6 : Call from app.comet.setTemplateID
7 : Insertion of an existing 1:N page element
8 : Reorganization
gPage
Current page number (not index)
Output variables¶
Variable
Data type
Description
gProducts
Current, complete list of products to build,
including all page templates and the current product.
Changes made on the list or the product
will change the result of the build.
Only filled in calls by the product build (gScriptType = 2 or 3).
kContextStampAction¶
Input variables¶
Variable
Data type
Description
gDocument
The current document
gDocumentID
Document ID of the current document
gFrame
The currently active frame
gOriginalFrame
The original frame
gCounter
The current stamp number
kContextExcelQueryFunction¶
Input variables¶
Variable
Data type
Description
gRecordID
ID of the preview entry which triggered the script.
Note that these IDs are normally no valid object IDs.
gRecordID2
gRecordID3
gRecordStringID
gRecordStringID1
gRecordStringID2
gRecordStringID3
gPSRecordId
gPSGroupId
gPSEntityId
gPSEntityClass
gPSParentRecordId
gPSParentGroupId
gPSParentEntityId
gPSParentEntityClass
gExcelPath
Full path to the open Excel file.
gResultString
Contains the current text and may be changed.
gExcel
The currently opened Excel file. May not be closed during the script.
Output variables¶
Variable
Data type
Description
gResultString
Contains the current text and may be changed.
kContextJob¶
Input variables¶
Variable
Data type
Description
gJobsQueueID
The job ID which was set during creation of the job.
Output variables¶
Variable
Data type
Description
gDocsKeptOpen
How many documents does this job script leave open without closing?
gOpenedDoc
When the job script opens a document, this variable can be set to instruct InDesign®
to wait for starting the next job until this document has finished closing.
Instead of setting this variable, the function jobs.registerDocument()
can be used.
Make sure to close the document in the job script.