Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

VisioShape

OfficeIMO.Visio

Namespace
OfficeIMO.Visio
Assembly
OfficeIMO.Visio
Source revision
0eef6a5756b9 with working tree changes

Represents a shape on a Visio page.

Inheritance

  • object
  • VisioShape

Usage

Explore 302 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 156

Accepted by parameters 146

Constructors

VisioShape 2 overloads
public VisioShape(string id) #

Initializes a new instance of the VisioShape class with the specified identifier.

Parameters

id string required
Identifier of the shape.
public VisioShape(string id, OfficeLength pinX, OfficeLength pinY, OfficeLength width, OfficeLength height, string text) #

Creates geometry from explicit physical lengths.

Parameters

id string required
pinX OfficeIMO.OfficeLength required
pinY OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
text string required

Methods

AddHyperlink 2 overloads
public VisioShape ClearLayoutPolicy() #

Clears explicit Shape Layout override cells from this shape.

Returns

VisioShape
public VisioShape ClearProtection() #

Clears explicit ShapeSheet protection cells from this shape.

Returns

VisioShape
public VisioShape? FindDescendantById(string id) #

Recursively searches the shape hierarchy for a shape with the provided identifier.

Parameters

id string required
Identifier to locate.

Returns

VisioShape? The matching shape when found; otherwise null.
public VisioShapeDataRow? FindShapeData(string name) #

Finds a Shape Data row by row name.

Parameters

name string required
Shape Data row name.
public VisioUserCell? FindUserCell(string name) #

Finds a user-defined ShapeSheet cell by row name.

Parameters

name string required
User cell row name.
public ValueTuple<double, double> GetAbsolutePoint(double x, double y) #

Transforms a point from the shape's local coordinate system to the page coordinate system.

Parameters

x double required
X coordinate of the point relative to the shape's local coordinate system.
y double required
Y coordinate of the point relative to the shape's local coordinate system.

Returns

ValueTuple<double, double> The point's absolute coordinates on the page, including cached reflections and every containing group.

Exceptions

  • InvalidDataException – A native reflection has neither a finite cache nor a constant numeric formula.
public ValueTuple<OfficeLength, OfficeLength, OfficeLength, OfficeLength> GetBounds() #

Gets the physical bounds in page coordinates, including rotation and parent transforms.

Returns

ValueTuple<OfficeLength, OfficeLength, OfficeLength, OfficeLength>
public string? GetShapeDataValue(string name) #

Gets a Shape Data value by row name.

Parameters

name string required
Shape Data row name.

Returns

string?
public string? GetUserCellValue(string name) #

Gets a user-defined ShapeSheet cell value by row name.

Parameters

name string required
User cell row name.

Returns

string?
public VisioShape LockPosition(bool locked = true) #

Locks or unlocks this shape's position.

Parameters

locked bool = true optional

Returns

VisioShape
public VisioShape LockSize(bool locked = true) #

Locks or unlocks this shape's size.

Parameters

locked bool = true optional

Returns

VisioShape
public VisioShape Protect(Action<VisioShapeProtection> configure) #

Configures ShapeSheet protection cells for this shape.

Parameters

configure System.Action<OfficeIMO.Visio.VisioShapeProtection> required
Protection configuration delegate.

Returns

VisioShape
public VisioShape SetBaseline(OfficeTextBaseline baseline) #

Sets the native baseline placement for the whole-shape text.

Parameters

baseline OfficeIMO.Drawing.OfficeTextBaseline required

Returns

VisioShape
public VisioShape SetBold(bool enabled = true) #

Sets whether the whole-shape text is bold.

Parameters

enabled bool = true optional

Returns

VisioShape
public VisioShape SetCapitalization(VisioTextCapitalization capitalization) #

Sets Visio's native display-time capitalization for the whole-shape text.

Parameters

capitalization OfficeIMO.Visio.VisioTextCapitalization required

Returns

VisioShape
public VisioShape SetConnectorPermeability(bool horizontal = true, bool vertical = true) #

Allows or disallows connector routing through this shape.

Parameters

horizontal bool = true optional
vertical bool = true optional

Returns

VisioShape
public VisioShape SetFill(OfficeColor color, int pattern = 1) #

Sets fill color and optional pattern.

Parameters

color OfficeIMO.OfficeColor required
Fill color.
pattern int = 1 optional
Fill pattern index (default 1=Solid).

Returns

VisioShape
public VisioShape SetFont(string fontFamily) #

Sets the whole-shape text font family.

Parameters

fontFamily string required

Returns

VisioShape
public VisioShape SetFontSize(double size) #

Sets the whole-shape text size in points.

Parameters

size double required

Returns

VisioShape
public VisioShape SetItalic(bool enabled = true) #

Sets whether the whole-shape text is italic.

Parameters

enabled bool = true optional

Returns

VisioShape
public VisioShape SetLayer(string layerName) #

Adds the shape to a page layer.

Parameters

layerName string required
Layer name.

Returns

VisioShape
public VisioShape SetPlacementFlip(VisioPlacementFlip flip) #

Sets the shape-level Visio placement flip behavior.

Parameters

flip OfficeIMO.Visio.VisioPlacementFlip required

Returns

VisioShape
public VisioShape SetPlacementOnTop(bool allowed = true) #

Allows or disallows placing other shapes on top of this shape during layout.

Parameters

allowed bool = true optional

Returns

VisioShape
public VisioShape SetPlacementStyle(VisioPlacementStyle style) #

Sets the shape-level Visio placement style.

Parameters

style OfficeIMO.Visio.VisioPlacementStyle required

Returns

VisioShape
public VisioShape SetPlow(VisioShapePlowCode code) #

Sets the shape-level Visio plow behavior.

Parameters

code OfficeIMO.Visio.VisioShapePlowCode required

Returns

VisioShape
public VisioShapeDataRow SetShapeData(string name, string? value, string? label = null, VisioShapeDataType? type = null, string? prompt = null, string? format = null) #

Sets or creates a Shape Data row.

Parameters

name string required
Shape Data row name.
value string? required
Shape Data value.
label string? = null optional
Optional label shown in Visio's Shape Data window.
type OfficeIMO.Visio.VisioShapeDataType? = null optional
Optional Shape Data type.
prompt string? = null optional
Optional help prompt.
format string? = null optional
Optional format picture or list values.
public VisioShape SetShapeSplitting(bool canSplit = true, bool canBeSplit = true) #

Allows or disallows this shape splitting other shapes.

Parameters

canSplit bool = true optional
canBeSplit bool = true optional

Returns

VisioShape
public VisioShape SetSmallCaps(bool enabled = true) #

Enables or disables Visio's native small-capital style.

Parameters

enabled bool = true optional

Returns

VisioShape
public VisioShape SetStrikethrough(OfficeTextDecorationStyle style = Single) #

Sets the native strikethrough variant for the whole-shape text.

Parameters

style OfficeIMO.Drawing.OfficeTextDecorationStyle = Single optional

Returns

VisioShape
public VisioShape SetStroke(OfficeColor color, double weight = 0.0138889, int pattern = 1) #

Sets stroke color, weight (inches), and optional pattern.

Parameters

color OfficeIMO.OfficeColor required
Line color.
weight double = 0.0138889 optional
Line weight in inches.
pattern int = 1 optional
Line pattern index (default 1=Solid).

Returns

VisioShape
public VisioShape SetText(string text) #

Sets shape text.

Parameters

text string required
Text content.

Returns

VisioShape
public VisioShape SetTextAlignment(OfficeAlignment horizontal, VisioTextVerticalAlignment? vertical = null) #

Sets whole-shape text alignment.

Parameters

horizontal OfficeIMO.OfficeAlignment required
vertical OfficeIMO.Visio.VisioTextVerticalAlignment? = null optional

Returns

VisioShape
public VisioShape SetTextColor(OfficeColor color) #

Sets the whole-shape text color.

Parameters

color OfficeIMO.OfficeColor required

Returns

VisioShape
public VisioShape SetUnderline(OfficeTextDecorationStyle style = Single) #

Sets the native underline variant for the whole-shape text.

Parameters

style OfficeIMO.Drawing.OfficeTextDecorationStyle = Single optional

Returns

VisioShape
public VisioUserCell SetUserCell(string name, string? value, string? unit = null, string? formula = null, string? prompt = null) #

Sets or creates a user-defined ShapeSheet cell.

Parameters

name string required
User cell row name.
value string? required
Value cell contents.
unit string? = null optional
Optional unit.
formula string? = null optional
Optional ShapeSheet formula.
prompt string? = null optional
Optional prompt.
public VisioShape TransformTextCase(OfficeTextCase textCase, CultureInfo? culture = null) #

Transforms the stored shape text while preserving all shape and text formatting.

Parameters

textCase OfficeIMO.Drawing.OfficeTextCase required
culture System.Globalization.CultureInfo? = null optional

Returns

VisioShape

Properties

public string Id { get; } #

Identifier of the shape.

public string? Name { get; set; } #

Gets or sets the shape name.

public string? NameU { get; set; } #

Gets or sets the universal name of the shape.

public string? Type { get; internal set; } #

Gets or sets the Visio type of the shape (for example "Group").

public VisioMaster? Master { get; set; } #

Gets or sets the master associated with the shape.

public string? MasterShapeId { get; internal set; } #

Gets the identifier of the referenced master shape when VisioShape.Master is defined.

public VisioShape? MasterShape { get; internal set; } #

Gets the master shape instance referenced by VisioShape.MasterShapeId, if any.

public string? MasterNameU { get; } #

Gets the universal name of the master.

public double LineWeight { get; set; } #

Gets or sets the line weight of the shape.

public double Angle { get; set; } #

Gets or sets the rotation angle of the shape in radians.

public string? Text { get; set; } #

Gets or sets the text contained in the shape.

public VisioTextStyle? TextStyle { get; set; } #

Gets or sets whole-shape text formatting.

public OfficeColor LineColor { get; set; } #

Line (border) color of the shape.

public OfficeColor FillColor { get; set; } #

Fill color of the shape.

public int LinePattern { get; set; } #

Line pattern (0=None, 1=Solid, 2=Dashed, etc.).

public int FillPattern { get; set; } #

Fill pattern (0=None, 1=Solid, etc.).

public VisioShape? Parent { get; internal set; } #

Parent shape when part of a group hierarchy.

public IList<VisioShape> Children { get; } #

Child shapes when this shape represents a group.

public IList<VisioConnectionPoint> ConnectionPoints { get; } #

Connection points associated with the shape.

public ISet<string> LayerNames { get; } #

Page layer names this shape belongs to.

public IList<VisioUserCell> UserCells { get; } #

User-defined ShapeSheet cells attached to this shape.

public IList<VisioShapeDataRow> ShapeData { get; } #

Visio Shape Data rows attached to this shape.

public VisioShapeProtection Protection { get; } #

Visio ShapeSheet protection cells controlling interactive editing in Visio.

public VisioPlacementStyle? PlacementStyle { get; set; } #

Gets or sets the shape-level placement style Visio uses during page layout.

public VisioPlacementFlip? PlacementFlip { get; set; } #

Gets or sets how Visio may flip or rotate this shape during page layout.

public VisioShapePlowCode? PlowCode { get; set; } #

Gets or sets whether this shape moves away when another placeable shape is dropped nearby.

public bool? AllowPlacementOnTop { get; set; } #

Gets or sets whether other placeable shapes may be placed on top of this shape during layout.

public bool? AllowHorizontalConnectorRoutingThrough { get; set; } #

Gets or sets whether connectors may route horizontally through this shape.

public bool? AllowVerticalConnectorRoutingThrough { get; set; } #

Gets or sets whether connectors may route vertically through this shape.

public bool? CanSplitShapes { get; set; } #

Gets or sets whether this shape may split other splittable shapes.

public bool? CanBeSplit { get; set; } #

Gets or sets whether this shape can be split by another shape.

public IList<string> ContainerMemberIds { get; } #

Shape identifiers this shape contains when it is used as a container.

public IList<string> ContainerOwnerIds { get; } #

Container shape identifiers this shape belongs to.

public bool IsContainer { get; } #

Gets whether this shape is marked as a Visio container.

public bool IsCallout { get; } #

Gets whether this shape is marked as an OfficeIMO callout or annotation.

public bool IsBackgroundSurface { get; } #

Gets whether this shape is marked as a background surface such as a region, zone, lane, or band.

public bool IsDiagramAdornment { get; } #

Gets whether this shape is marked as a generated diagram adornment such as a title, legend item, or zone caption.

public string? CalloutTargetId { get; } #

Gets the target shape identifier for an OfficeIMO callout, if available.

public Dictionary<string, string> Data { get; } #

Arbitrary data associated with the shape.

public OfficeLength Width { get; set; } #

Gets or sets the physical Width.

public OfficeLength Height { get; set; } #

Gets or sets the physical Height.

public OfficeLength PinX { get; set; } #

Gets or sets the physical PinX.

public OfficeLength PinY { get; set; } #

Gets or sets the physical PinY.

public OfficeLength LocPinX { get; set; } #

Gets or sets the physical LocPinX.

public OfficeLength LocPinY { get; set; } #

Gets or sets the physical LocPinY.

Extension Methods

public static VisioShape ApplyStyle(VisioShape shape, VisioShapeStyle style) #

Applies a reusable style to a shape.

Parameters

shape OfficeIMO.Visio.VisioShape required
style OfficeIMO.Visio.VisioShapeStyle required

Returns

VisioShape
public static VisioShape ApplyTextStyle(VisioShape shape, VisioTextStyle style) #

Applies a reusable text style to a shape.

Parameters

shape OfficeIMO.Visio.VisioShape required
style OfficeIMO.Visio.VisioTextStyle required

Returns

VisioShape
public static VisioShapeBounds GetPageShapeBounds(VisioShape shape) #

Gets rotation-aware bounds in page coordinates, including every parent-group transform for a nested shape.

Parameters

shape OfficeIMO.Visio.VisioShape required
public static VisioShapeBounds GetShapeBounds(VisioShape shape) #

Gets the page-space bounds for a shape.

Parameters

shape OfficeIMO.Visio.VisioShape required
Shape to inspect.
public static IReadOnlyList<VisioShapeSheetSection> GetShapeSheetSections(VisioShape shape) #

Returns source-preserved ShapeSheet sections, including native text rows with current typed edits.

Parameters

shape OfficeIMO.Visio.VisioShape required

Returns

IReadOnlyList<VisioShapeSheetSection>
public static VisioShape MarkAsBackgroundSurface(VisioShape shape) #

Marks a shape as a background surface such as a zone, subnet, lane, band, or grouping region.

Parameters

shape OfficeIMO.Visio.VisioShape required
Shape to mark.

Returns

VisioShape
public static VisioShape MarkAsGeneratedDiagramAdornment(VisioShape shape) #

Marks a generated label, title, legend item, or caption as a diagram adornment that quality checks and routing can treat as non-domain content.

Parameters

shape OfficeIMO.Visio.VisioShape required
Shape to mark.

Returns

VisioShape
public static bool RemoveShapeSheetSection(VisioShape shape, string name) #

Removes a source-preserved section and clears any typed formatting owned by that text section.

Parameters

shape OfficeIMO.Visio.VisioShape required
name string required

Returns

bool
public static VisioShape ResizeToText(VisioShape shape, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.25, double verticalPadding = 0.14, double minimumWidth = 0.5, double minimumHeight = 0.3) #

Resizes a shape to fit its plain text using deterministic OfficeIMO.Drawing measurement.

Parameters

shape OfficeIMO.Visio.VisioShape required
Shape to resize.
fontInfo OfficeIMO.Drawing.OfficeFontInfo? = null optional
Font descriptor used for measurement. Uses Office default when omitted.
horizontalPadding double = 0.25 optional
Horizontal padding in inches.
verticalPadding double = 0.14 optional
Vertical padding in inches.
minimumWidth double = 0.5 optional
Minimum resulting width in inches.
minimumHeight double = 0.3 optional
Minimum resulting height in inches.

Returns

VisioShape
public static VisioShape SetShapeSheetSection(VisioShape shape, VisioShapeSheetSection section) #

Sets a typed ShapeSheet section without disturbing other preserved sections.

Parameters

shape OfficeIMO.Visio.VisioShape required
section OfficeIMO.Visio.VisioShapeSheetSection required

Returns

VisioShape