comet.CPageItem¶
- class comet.CPageItem¶
- Inherited by:
CPageItem is a reference to a document page item (e.g. a frame)
CPageItem is a reference to a document art object (e.g. a text frame)
Methods¶
- CPageItem.isValid()¶
Determine whether this item is still valid and exists in a document. An item may be invalid e.g. when it is deleted from the owning document by calling
remove()
- Returns
Whether the item is still valid
- Return type
- Available
- CScript
- CPageItem.getUID()¶
Get the UID of this item as an int.
- Returns
The UID of this item
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.getType()¶
Determine the type of the item.
- Returns
The type of the item.
One of Pageitem types
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.getDocument()¶
Get the document this item belongs to.
- Returns
The document
- Return type
- Raises
CometError – On internal error
- Available
- CPageItem.getPage(queryNearest=False)¶
Get the page this item is on.
- Parameters
queryNearest (bool) – When the item is not on a page find the closest page?
- Returns
The page the item is on
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPageItem.getLayer()¶
Get the layer this item is on.
- Returns
The item’s layer
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.setLayer(layer, moveGroup=False, ignoreLayerLocks=False)¶
Move this item to another layer.
- Parameters
layer (str | list[str] | int | CLayer) –
The new target layer.
The parameter type can be:
moveGroup (bool) –
True
: In case of sub or inline frames, the topmost item is moved instead.False
: Do not move sub or inline frames. The function will raiseCometError
in this case.
ignoreLayerLocks (bool) –
Allow moving from and to locked layers?
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter layer is empty str or invalid int or None
CometError – On internal error
- Available
- CScript
- CPageItem.getGroup()¶
Get the group this item belongs to, if any.
- Returns
The group if one exists, else
None
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.getName(nameType=0, translate=False)¶
Get the name of this item as displayed in the layer panel.
- Parameters
nameType (int) –
The kind of name to retrieve.
0: User defined name. If empty return the default name.
1: Default name
2: User defined name. If not set the result string is empty
translate (bool) –
Translate the default name?
The internal untranslated name of an empty graphic frame is #Graphicframe. This is translated to Graphic frame by an English version of InDesign®.
Ignored
- Returns
The name of this frame
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter nameType has invalid value.
CometError – On internal error
- Available
- CScript
- CPageItem.setName(name)¶
Set the name of this item.
- CPageItem.getBBox(spreadRelative=False)¶
Get the bounding box of this item.
- CPageItem.moveTo(x, y, page=- 1, executeLayoutRules=False)¶
Move a frame to new coordinates. The frame may also be moved to another page. The new position is the position of the left upper corner of the frame’s bounding box.
- Parameters
- Returns
None
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter page has invalid value
CometError – On internal error
- Available
- See also
- CScript
- CPageItem.getScale()¶
Get the item’s current scale factors.
- Returns
The scale factors (vertical, horizontal) where 1.0 = 100%.
- Return type
- Available
- CScript
- CPageItem.setScale(x, y, refPoint=0, executeLayoutRules=False)¶
Scale the item by the given factors.
- Parameters
x (float) – Width factor
y (float) – Height factor
refPoint –
The reference point to scale the frame around
Depending on the parameter type, the behavior changes as follows:
Ignored. The left top point is always used.
Default is
comet.kRefPointTopLeft
executeLayoutRules (bool) –
Execute layout rules “After geometry changes” while executing the command?
- Return type
- Raises
TypeError – When parameter types are invalid
When parameter x or y are <= 0.0
When parameter refPoint is of type
int
and has invalid value
CometError – On internal error
- Available
- CScript
- CPageItem.getRotation()¶
Get the item’s rotation
- Returns
The rotation in degrees
- Return type
- Available
- CScript
- CPageItem.setRotation(angle, refPoint=4, executeLayoutRules=False)¶
Rotate the item around it’s own reference point.
The rotation angle is absolute.
- Parameters
angle (float) – The angle to rotate the item in degrees counter clockwise
refPoint (int) –
The reference point which is fixed during rotation.
One of Reference Points.
Default is
comet.kRefPointCenter
.executeLayoutRules (bool) –
Execute layout rules “After geometry changes” while executing the command?
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter refPoint has invalid value
CometError – On internal error
- Available
- CScript
- CPageItem.getSkew()¶
Get the current skew angle of the item.
- Returns
The current skew angle
- Return type
- Available
- CScript
- CPageItem.setSkew(angle, refPoint=0, executeLayoutRules=False)¶
Skew an item horizontally. For a vertical skew, use the negative angle to skew followed by a rotation to the negative angle (use the same reference point for both transformations!).
- Parameters
angle (float) – The skew angle
refPoint (int | tuple[float, float]) –
The reference point to scale the item around
Depending on the parameter type, the behavior changes as follows:
Use a defined reference point. Value must be one of Reference Points
Ignored. The left top point is always used.
Default is
comet.kRefPointTopLeft
executeLayoutRules (bool) –
Execute layout rules “After geometry changes” while executing the command?
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter refPoint is of type
int
and has invalid valueCometError – On internal error
- Available
- CScript
- CPageItem.getLocked()¶
Returns whether the item is locked.
- Returns
Whether the item is locked
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.setLocked(locked=True)¶
Set the lock state of the item.
- Parameters
locked (bool) – The new lock state
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPageItem.getVisible()¶
Determine whether the item is visible or hidden.
- Returns
Whether the item is visible
- Return type
- Available
- CScript
- CPageItem.setVisible(visible=True)¶
Set the visibility state of this item.
- CPageItem.getPrintable()¶
Get the printability of the item (printing and PDF exports).
- Returns
Whether the item is marked as printable
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.setPrintable(enable)¶
Set the printability of the item (printing and PDF exports).
- Parameters
enable (bool) – Enable printability?
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPageItem.getOverprint(what=0)¶
Get the overprint setting of the item.
- Parameters
what (int) –
Which setting to query
One of Overprint settings
Default is
comet.kOverprintBasic
- Returns
Whether overprint is active for the queried setting
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPageItem.setOverprint(enable, what=0)¶
Set the overprint setting of the item.
- Parameters
enable (bool) – Enable the specified setting?
what (int) –
Which setting to change
One of Overprint settings
Default is
comet.kOverprintBasic
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPageItem.getObjectStyle(translate=False)¶
Get the full path to this item’s object style.
When the style if part of a hierarchy, the name is delimited by ‘:’
- Parameters
translate (bool) –
Translate default names?
- Returns
Full path to the object style
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.setObjectStyle(stylePath, removeOverrides=False)¶
Set this item’s object style.
- Parameters
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPageItem.getOpacity(type=0)¶
Get the opacity of this item.
- Parameters
type (int) –
Which opacity type to get.
0 : Object
1 : Stroke
2 : Fill
3 : Content
- Returns
The opacity in range[0.0, 100.0]
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter type has invalid value
CometError – On internal error
- Available
- CScript
- CPageItem.getFillColor()¶
Get the primary fill color of this item.
- Returns
The color and swatch if any is applied, else
None
.- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.setFillColor(color)¶
Set the primary fill color of this item.
- Parameters
color (CColor | CSwatch | str | tuple[int, int, int] | tuple[float, float, float, float]) –
The color data to apply.
The parameter type can be:
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter color is invalid or any provided values inside are invalid
CometError – On internal error
- Available
- CScript
- CPageItem.getScriptTag(key)¶
Get the value of a single script tag. Returns
None
when the key does not exist.- Parameters
key (str) – The script tag key to get the value for
- Returns
The found value or
None
if the key does not exist.Only values of type
str
are supported. Other data types get converted to string representations of their values.- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter key is empty
CometError – On internal error
- Available
- CScript
- CPageItem.getScriptTags()¶
Fetches all script tags of the item. Data types may vary depending on the tag type.
- Returns
A list of all script tags as key/values.
Only values of type
str
are supported. Other data types get converted to string representations of their values.- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPageItem.setScriptTag(key, value)¶
Set the value of a script tag. The value is overwritten if it already exists.
- Parameters
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameters key is empty
CometError – On internal error
- Available
- CScript
- CPageItem.removeScriptTags(keys)¶
Remove script tags.
- Parameters
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Return type
- Available
- CPageItem.remove()¶
Deletes this item and all it’s children from it’s document.
All subsequent calls to this item’s or the item’s children functions will fail.
- Return type
- Raises
CometError – On internal error
- Available
- CScript