Shape class

Shape class

Contains elements that define a shape in a Master, Page, or group shape element.

The Shape type exposes the following members:

Constructors

Constructor Description
Shape() Constructor.

Properties

Property Description
id The unique ID of the element within its parent element.
unique_id A GUID (globally unique identifier) assigned to the shape.
name The name of the element.
name_u The universal name of the element.
type The type of a shape. It may be one of the following values: Group, Shape, Guide, or Foreign.
line_style StyleSheet from which this shape inherits line formatting
fill_style StyleSheet from which this shape inherits fill formatting.
text_style StyleSheet from which this shape inherits text formatting.
shapes Contains a collection of Shape elements.
text Contains the text of a shape.
x_form Contains elements specifying general positioning information about a shape.
line Contains elements that control line attributes for a shape, such as pattern, weight, and color. These elements determine whether the line ends are formatted (for example, with an arrowhead), the size of line end formats, radius of the rounding circle applied to the line, and line cap style (round or square).
fill Contains the current fill formatting values for the shape and the shape’s drop shadow, including pattern, foreground color, and background color.
inherit_chars Contains the char values for the shape inherit by the master shape.
inherit_props Contains the props for the shape inherit by the master shape.
inherit_users Contains the users for the shape inherit by the master shape.
inherit_geoms Contains the Geoms values for the shape inherit by the master shape.
inherit_paras Contains the paras for the shape inherit by the parent style and the master shape.
inherit_text_block Contains the textblock values for the shape inherit by the parent style and the master shape.
inherit_line Contains the line formatting values for the shape inherit by the parent style and the master shape.
inherit_fill Contains the fill formatting values for the shape inherit by the parent style and the master shape.
x_form_1d Contains x- and y-coordinates of the begin point and end point of a 1-D shape. This element appears for 1-D shapes only.
event Contains elements that specify formulas that control shape events.
layer_mem Contains the LayerMember element, which specifies each layer to which the shape is assigned.
foreign Contains elements specifying the width and height of an object from another program used in a Microsoft Visio document. Also includes elements specifying the distance the object’s image is offset within its borders.
text_block Contains elements that specify the alignment, margins, and default tab stop positions of text in a shape’s text block.
text_x_form Contains elements that specify positioning information about a shape’s text block.
align Indicates the alignment of a shape with respect to the guide or guide point to which the shape is glued. The Align element appears only for shapes that are glued to guides or guide points.
protection Locking helps prevent inadvertent changes to the shape but does not prevent Microsoft Visio from resetting values in other circumstances. It also does not protect against changes made in the ShapeSheet window.
help Contains elements specifying the Shape element’s Help file topic and copyright information.
misc Contains elements specifying the Shape element’s Help file topic and copyright information.
image Contains the gamma, brightness, contrast, blur, sharpen, denoise, and transparency values for a bitmap.
group Contains elements that control how you add shapes to a group, move members of a group, and select groups.
layout Contains elements that control shape placement and connector routing settings.
chars Contains a collection of Char elements.
paras Contains a collection of Para elements.
scratchs Contains a collection of Scratch elements.
connections Contains a collection of Connection elements.
connection_abc_ds Contains a collection of ConnectionABCD elements.
fields Contains a collection of Field elements.
controls Contains a collection of Control elements.
geoms Contains a collection of Geom elements.
acts Contains a collection of Act elements.
users Contains a collection of User elements.
props Contains a collection of Prop elements.
hyperlinks Contains a collection of Hyperlink elements.
smart_tag_defs Contains a collection of SmartTagDef elements.
tabs_collection Contains a collection of Tab elements.
data1 Contains an arbitrary string value that is used to supply additional information about a shape.
data2 Contains an arbitrary string value that is used to supply additional information about a shape.
data3 Contains an arbitrary string value that is used to supply additional information about a shape.
clipping_path
foreign_data Contains a MIME (Multipurpose Internet Mail Extensions) encoded BLOB of picture data, such as Windows metafile, bitmap, or OLE data.
master_shape This attribute may only be present in shapes that are members of a group shape, and the group is an instance of a master. The attribute contains an ID that references the corresponding sub-shape in the master.
master The Master from which the shape inherits its data.
parent_shape Shape’s parent.
root_shape Returns the top-level shape of an instance if this shape is part of a master instance. Read-only.
diagram Root element of Visio objects hierarchy.
page Root element of Visio objects hierarchy.
one_d Determines whether the shape behaves as a one-dimensional (1-D) object. Read-only.
two_d Determines whether the shape behaves as a two-dimensional (2-D) object.
is_text_empty Indicate the shape has text and the text is empty or not.
control_data Gets the data of control.
active_x_control Gets the ActiveX control.
z_order_index Returns the index of a shape in the z-order except the guide shape.
three_d_format Gets the ThreeDFormat.

Methods

Method Description
to_pdf(file_name) Saves the shape to a pdf file.
to_pdf(stream) Creates the shape pdf and saves it to a stream.
to_image(image_file, options) Creates the shape image and saves it to a file.
The extension of the file name determines the format of the image.
to_image(stream, options) Creates the shape image and saves it to a stream in the specified format.
to_html(file_name, options) Creates the html and saves it to a file.
to_html(stream, options) Creates the shape html and saves it to a stream in the specified format.
get_connectors_type() Get Connectors type
set_connectors_type(type) Set Connectors type
set_preset_theme_style_matrics(style_index, color_index) pply a preset theme variant quickstyle to this shape, like theme styles options in shape styles dropdown list
copy(source)
bring_forward() Brings the shape forward one position in the z-order.
send_backward() Moves the shape back one position in the z-order.
bring_to_front() Brings the shape to the front of the z-order.
send_to_back() Moves the shape to the back of the z-order.
get_connector_rule() Returns a connectorRule that contains the shape id and connecton that are connected to the shape.
connected_shapes(flag, category_filter)
is_in_group() Indicates whether this shape is in a group shape.
is_contain(shape)
is_intersect(shape)
is_connected(shape)
center_drawing() Center the shape with respect to the extent of the page
is_glued(shape)
refresh_data() Refreshes shape’s position including xform ,connection and geom when changing shape’s text or other’s .
glued_shapes(flag, category_filter, other_shape)
depends_on_shapes()
set_width(width) Sets new width of shape.
set_height(height) Sets new height of shape.
set_angle(angle) Sets new angle of shape.
The angle’s unit is radian.
move_to(new_pin_x, new_pin_y) Moves shape on new absolute position on the page.
move(d_x, d_y) Moves shape on the dX and dY inches from current position.
get_display_text() Get the text displayed on the interface
get_pure_text() Get the text string
ungroup() Ungroup Shape
replace_text(text, replace_text) Replace the text string of a shape .
to_svg(image_file, options) Saves the shape to a svg file.

See Also