Previous Document Next Document

Including queries in macros : Understanding the available query criteria : Querying shapes


Querying shapes

You can query the shapes on a page or layer.

To access the properties and methods of the current shape, you must prepend the property name or method name with the at sign ( @ ). Thus, @type calls the Shape.Type property of the current shape.

 
You can call an expression without specifying the current shape. However, in this case, the @ operator is unavailable.

Shape queries can return values of any of the other supported object type (see Understanding the available query criteria). For example, if the expression is evaluated on a shape object in a document and that shape object exposes a fill property that returns a color object, the following expression can be called to determine whether the current shape has a red fill:

@fill.color.name = 'Red'

Shapes support the following query criteria:

Query criteria
Description
Example and result
shape.Bottom()
Returns the vertical position of the bottom edge of the shape on the page
@bottom < {4 in}
Checks whether the bottom edge of the shape is above the vertical 4-inch mark on the page
shape.CenterX()
Returns the horizontal position of the center of the shape on the page
@centerX = {4.25 in}
Checks whether the center of the shape is at the horizontal 4.25-inch mark on the page
shape.CenterY()
Returns the vertical position of the top center of the shape on the page
@CenterY = {5.5 in}
Checks whether the top center of the shape is at the vertical 5.5-inch mark on the page
shape.Colors()
Returns an array of colors used in the fill and outline of the shape. This array contains only unique colors, so if the fill and the outline have the same color, only one color is returned.
@colors.find(cmyk(0,0,0,100))
Checks whether the shape contains a CMYK black color
 
 
[email protected]($item.cmyk.k <> 0).empty
Checks whether the shape has any colors with a non-empty black color component
shape.COM()
Returns the COM object for the shape. This method allows access to any property and function of the shape object and its subobject — items that are not directly accessible by CQL.
(@com.transparency.type = 1)
Checks whether the shape has a uniform transparency applied to it. Refer to the Object Model Reference. section for details on objects and methods.
shape.Fill()
Returns the fill object representing the shape fill
@fill.type = 'uniform'
Checks whether the shape has a uniform fill applied to it
shape.Height()
Returns the height of the shape, in the current unit of measurement
@height = {20 mm}
Checks whether the shape is 20 mm high
shape.Left()
Returns the horizontal position of the left edge of the shape on the page
@left = {0 mm}
Checks whether the left edge of the shape is at the horizontal 0-millimeter mark on the page
shape.Name()
Returns the name of the current shape
@name = 'MyShape'
Checks whether the shape is named MyShape
shape.Outline()
Returns the outline object representing the shape outline
@outline.color = 'red'
Checks whether the shape has a red outline applied to it
shape.Right()
Returns the horizontal position of the right edge of the shape on the page
@right > {8.5 in}
Checks whether the right edge of the shape is past the horizontal 8.5-inch mark on the page
shape.Top()
Returns the vertical position of the top edge of the shape on the page
@top = {11 in}
Checks whether the top edge of the shape is at the vertical 11-inch mark on the page
shape.Type()
Returns a string representing the shape type. The value returned is 'rectangle', 'ellipse', 'curve', 'polygon', and so on.
@type = 'polygon'
Checks whether the shape is a polygon
shape.Width()
Returns the width of the shape, in the current unit of measurement
@width > {1 in}
Checks whether the shape is less than 1 inch wide

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.