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

ConstructorDescription
Shape()Constructor.

Properties

PropertyDescription
idThe unique ID of the element within its parent element.
unique_idA GUID (globally unique identifier) assigned to the shape.
nameThe name of the element.
name_uThe universal name of the element.
typeThe type of a shape. It may be one of the following values: Group, Shape, Guide, or Foreign.
line_styleStyleSheet from which this shape inherits line formatting
fill_styleStyleSheet from which this shape inherits fill formatting.
text_styleStyleSheet from which this shape inherits text formatting.
shapesContains a collection of Shape elements.
textContains the text of a shape.
x_formContains elements specifying general positioning information about a shape.
lineContains 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).
fillContains the current fill formatting values for the shape and the shape’s drop shadow, including pattern, foreground color, and background color.
inherit_charsContains the char values for the shape inherit by the master shape.
inherit_propsContains the props for the shape inherit by the master shape.
inherit_usersContains the users for the shape inherit by the master shape.
inherit_geomsContains the Geoms values for the shape inherit by the master shape.
inherit_parasContains the paras for the shape inherit by the parent style and the master shape.
inherit_text_blockContains the textblock values for the shape inherit by the parent style and the master shape.
inherit_lineContains the line formatting values for the shape inherit by the parent style and the master shape.
inherit_fillContains the fill formatting values for the shape inherit by the parent style and the master shape.
x_form_1dContains x- and y-coordinates of the begin point and end point of a 1-D shape. This element appears for 1-D shapes only.
eventContains elements that specify formulas that control shape events.
layer_memContains the LayerMember element, which specifies each layer to which the shape is assigned.
foreignContains 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_blockContains elements that specify the alignment, margins, and default tab stop positions of text in a shape’s text block.
text_x_formContains elements that specify positioning information about a shape’s text block.
alignIndicates 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.
protectionLocking 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.
helpContains elements specifying the Shape element’s Help file topic and copyright information.
miscContains elements specifying the Shape element’s Help file topic and copyright information.
imageContains the gamma, brightness, contrast, blur, sharpen, denoise, and transparency values for a bitmap.
groupContains elements that control how you add shapes to a group, move members of a group, and select groups.
layoutContains elements that control shape placement and connector routing settings.
charsContains a collection of Char elements.
parasContains a collection of Para elements.
scratchsContains a collection of Scratch elements.
connectionsContains a collection of Connection elements.
connection_abc_dsContains a collection of ConnectionABCD elements.
fieldsContains a collection of Field elements.
controlsContains a collection of Control elements.
geomsContains a collection of Geom elements.
actsContains a collection of Act elements.
usersContains a collection of User elements.
propsContains a collection of Prop elements.
hyperlinksContains a collection of Hyperlink elements.
smart_tag_defsContains a collection of SmartTagDef elements.
tabs_collectionContains a collection of Tab elements.
data1Contains an arbitrary string value that is used to supply additional information about a shape.
data2Contains an arbitrary string value that is used to supply additional information about a shape.
data3Contains an arbitrary string value that is used to supply additional information about a shape.
clipping_path
foreign_dataContains a MIME (Multipurpose Internet Mail Extensions) encoded BLOB of picture data, such as Windows metafile, bitmap, or OLE data.
master_shapeThis 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.
masterThe Master from which the shape inherits its data.
parent_shapeShape’s parent.
root_shapeReturns the top-level shape of an instance if this shape is part of a master instance. Read-only.
diagramRoot element of Visio objects hierarchy.
pageRoot element of Visio objects hierarchy.
one_dDetermines whether the shape behaves as a one-dimensional (1-D) object. Read-only.
two_dDetermines whether the shape behaves as a two-dimensional (2-D) object.
is_text_emptyIndicate the shape has text and the text is empty or not.
control_dataGets the data of control.
active_x_controlGets the ActiveX control.
z_order_indexReturns the index of a shape in the z-order except the guide shape.
three_d_formatGets the ThreeDFormat.

Methods

MethodDescription
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