Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

VisioLayoutExtensions

OfficeIMO.Visio

Namespace
OfficeIMO.Visio
Assembly
OfficeIMO.Visio
Source revision
273d35d5ba8a with working tree changes
Modifiers
static

Layout and geometry helpers for Visio pages, shapes, and selections.

Inheritance

  • object
  • VisioLayoutExtensions

Methods

Align 2 overloads
public static VisioShapeSelection Align(VisioShapeSelection selection, VisioHorizontalAlignment alignment) #

Aligns selected shapes horizontally inside the current selection bounds.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to align.
alignment OfficeIMO.Visio.VisioHorizontalAlignment required
Horizontal alignment.
public static VisioShapeSelection Align(VisioShapeSelection selection, VisioVerticalAlignment alignment) #

Aligns selected shapes vertically inside the current selection bounds.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to align.
alignment OfficeIMO.Visio.VisioVerticalAlignment required
Vertical alignment.
public static VisioPage CenterContent(VisioPage page) #

Centers top-level page shapes within the current page size.

Parameters

page OfficeIMO.Visio.VisioPage required
Page to update.

Returns

VisioPage
public static VisioShapeSelection Distribute(VisioShapeSelection selection, VisioDistributionAxis axis) #

Distributes selected shapes by center point along the requested axis.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to distribute.
axis OfficeIMO.Visio.VisioDistributionAxis required
Distribution axis.
public static VisioShapeSelection DistributeHorizontally(VisioShapeSelection selection) #

Distributes selected shapes horizontally by center point.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to distribute.
public static VisioShapeSelection DistributeVertically(VisioShapeSelection selection) #

Distributes selected shapes vertically by center point.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to distribute.
FitToContent 3 overloads
public static VisioPage FitToContent(VisioPage page, double margin = 0.5, bool resizePage = true) #

Moves top-level page shapes so content starts at the requested margin and optionally resizes the page to fit.

Parameters

page OfficeIMO.Visio.VisioPage required
Page to update.
margin double = 0.5 optional
Margin in inches around content.
resizePage bool = true optional
Whether to resize the page around the content.

Returns

VisioPage
public static VisioPage FitToContent(VisioPage page, VisioFitToContentOptions options) #

Fits an imported page using explicit group-child, connector-route, translation, and resize policies. Rotation-aware shape bounds and connector label boxes are used.

Parameters

page OfficeIMO.Visio.VisioPage required
options OfficeIMO.Visio.VisioFitToContentOptions required

Returns

VisioPage
public static VisioPage FitToContent(VisioPage page, double horizontalMargin, double verticalMargin, bool resizePage = true) #

Moves top-level page shapes so content starts at the requested margins and optionally resizes the page to fit.

Parameters

page OfficeIMO.Visio.VisioPage required
Page to update.
horizontalMargin double required
Horizontal margin in inches.
verticalMargin double required
Vertical margin in inches.
resizePage bool = true optional
Whether to resize the page around the content.

Returns

VisioPage
public static VisioShapeBounds GetConnectorContentBounds(VisioConnector connector) #

Gets connector route and label bounds in page inches.

Parameters

connector OfficeIMO.Visio.VisioConnector required
public static VisioShapeBounds GetContentBounds(VisioPage page, bool includeGroupChildren = false, bool includeConnectors = true) #

Gets bounds of visible page content, including shapes, explicit connector routes, and connector label boxes.

Parameters

page OfficeIMO.Visio.VisioPage required
Page to inspect.
includeGroupChildren bool = false optional
Whether nested group children should be included using their stored coordinates.
includeConnectors bool = true optional
Whether connector waypoints and label boxes should be included.
public static VisioShapeBounds GetLabelBounds(VisioConnector connector) #

Gets the explicitly placed connector label bounds in page inches, or empty bounds when no label is placed.

Parameters

connector OfficeIMO.Visio.VisioConnector required
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
GetShapeBounds 3 overloads
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 VisioShapeBounds GetShapeBounds(IEnumerable<VisioShape> shapes) #

Gets aggregate bounds for a shape sequence.

Parameters

shapes System.Collections.Generic.IEnumerable<OfficeIMO.Visio.VisioShape> required
Shapes to inspect.
public static VisioShapeBounds GetShapeBounds(VisioShapeSelection selection) #

Gets the bounds of a shape selection.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to inspect.
RelayoutAsGrid 2 overloads
public static VisioShapeSelection RelayoutAsGrid(VisioShapeSelection selection, int columns = 0, double horizontalSpacing = 0.5, double verticalSpacing = 0.5, bool routeInternalConnectors = true) #

Relays out selected shapes into a deterministic grid and optionally reroutes internal connectors.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to relayout.
columns int = 0 optional
Number of columns. When zero, OfficeIMO uses a near-square grid.
horizontalSpacing double = 0.5 optional
Horizontal spacing between columns in inches.
verticalSpacing double = 0.5 optional
Vertical spacing between rows in inches.
routeInternalConnectors bool = true optional
Whether connectors whose endpoints are both selected should be rerouted orthogonally.
public static VisioShapeSelection RelayoutAsGrid(VisioShapeSelection selection, VisioSelectionLayoutOptions? options) #

Relays out selected shapes into a deterministic grid and optionally reroutes internal connectors.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to relayout.
options OfficeIMO.Visio.VisioSelectionLayoutOptions? required
Layout options.
public static VisioShapeSelection RelayoutAsHorizontalStack(VisioShapeSelection selection, double spacing = 0.5, bool routeInternalConnectors = true) #

Relays out selected shapes as a horizontal row and optionally reroutes internal connectors.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to relayout.
spacing double = 0.5 optional
Horizontal spacing between shapes in inches.
routeInternalConnectors bool = true optional
Whether connectors whose endpoints are both selected should be rerouted orthogonally.
public static VisioShapeSelection RelayoutAsVerticalStack(VisioShapeSelection selection, double spacing = 0.5, bool routeInternalConnectors = true) #

Relays out selected shapes as a vertical stack and optionally reroutes internal connectors.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection to relayout.
spacing double = 0.5 optional
Vertical spacing between shapes in inches.
routeInternalConnectors bool = true optional
Whether connectors whose endpoints are both selected should be rerouted orthogonally.
public static VisioConnectorSelection ResizeLabelsToText(VisioConnectorSelection selection, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.12, double verticalPadding = 0.06, double minimumWidth = 0.45, double minimumHeight = 0.22, double? maximumWidth = null) #

Resizes selected connector label text boxes to fit their plain text using deterministic OfficeIMO.Drawing measurement.

Parameters

selection OfficeIMO.Visio.VisioConnectorSelection required
Connector selection.
fontInfo OfficeIMO.Drawing.OfficeFontInfo? = null optional
Font descriptor used for measurement. Uses connector text style, then Office default, when omitted.
horizontalPadding double = 0.12 optional
Horizontal padding in inches.
verticalPadding double = 0.06 optional
Vertical padding in inches.
minimumWidth double = 0.45 optional
Minimum resulting label width in inches.
minimumHeight double = 0.22 optional
Minimum resulting label height in inches.
maximumWidth double? = null optional
Optional maximum label width in inches. Text wraps by words when supplied.
public static VisioConnector ResizeLabelToText(VisioConnector connector, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.12, double verticalPadding = 0.06, double minimumWidth = 0.45, double minimumHeight = 0.22, double? maximumWidth = null) #

Resizes a connector label text box to fit its plain text using deterministic OfficeIMO.Drawing measurement.

Parameters

connector OfficeIMO.Visio.VisioConnector required
Connector whose label box should be resized.
fontInfo OfficeIMO.Drawing.OfficeFontInfo? = null optional
Font descriptor used for measurement. Uses connector text style, then Office default, when omitted.
horizontalPadding double = 0.12 optional
Horizontal padding in inches.
verticalPadding double = 0.06 optional
Vertical padding in inches.
minimumWidth double = 0.45 optional
Minimum resulting label width in inches.
minimumHeight double = 0.22 optional
Minimum resulting label height in inches.
maximumWidth double? = null optional
Optional maximum label width in inches. Text wraps by words when supplied.
ResizeToText 2 overloads
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 VisioShapeSelection ResizeToText(VisioShapeSelection selection, OfficeFontInfo? fontInfo = null, double horizontalPadding = 0.25, double verticalPadding = 0.14, double minimumWidth = 0.5, double minimumHeight = 0.3) #

Resizes selected shapes to fit their plain text using deterministic OfficeIMO.Drawing measurement.

Parameters

selection OfficeIMO.Visio.VisioShapeSelection required
Selection 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.
public static VisioPage ResolveConnectorLabelOverlaps(VisioPage page, double step = 0.18, int maxAttempts = 12, bool avoidShapes = true, bool avoidLabels = true, bool preferEndpointZones = false, bool avoidConnectorPaths = true, double positionStep = 0.08, int maxPositionShifts = 4, int optimizationPasses = 1) #

Moves connector label boxes away from page edges, unrelated shapes, and previously placed connector labels.

Parameters

page OfficeIMO.Visio.VisioPage required
Page whose connector labels should be adjusted.
step double = 0.18 optional
Search step in page units, expressed in inches.
maxAttempts int = 12 optional
Number of search rings to try around the current label position.
avoidShapes bool = true optional
Whether labels should avoid unrelated non-container shapes.
avoidLabels bool = true optional
Whether labels should avoid other connector labels.
preferEndpointZones bool = false optional
Whether labels should prefer common endpoint zones and avoid unrelated background zones.
avoidConnectorPaths bool = true optional
Whether labels should avoid unrelated connector paths.
positionStep double = 0.08 optional
Connector path-position search step, from 0.0 to 1.0.
maxPositionShifts int = 4 optional
Number of positive and negative connector path-position shifts to try.
optimizationPasses int = 1 optional
Number of whole-page label optimization passes to run after the initial placement sweep.

Returns

VisioPage
public static VisioPage ResolveShapeOverlaps(VisioPage page, double step = 0.25, int maxAttempts = 24, bool includeContainers = false) #

Moves overlapping top-level shapes apart using a deterministic nearest-open-position search.

Parameters

page OfficeIMO.Visio.VisioPage required
Page to update.
step double = 0.25 optional
Search step in inches.
maxAttempts int = 24 optional
Number of search rings to try around each overlapping shape.
includeContainers bool = false optional
Whether container and background surface shapes should be moved and treated as obstacles.

Returns

VisioPage