# Use Visio Stencils and Shape Catalogs

Place shapes from OfficeIMO's built-in catalogs or from VSSX and VSTX stencil packs you supply, and keep the link to each shape's master.

**Packages**

- [OfficeIMO.Visio](https://www.nuget.org/packages/OfficeIMO.Visio) `dotnet add package OfficeIMO.Visio`

**Works with**

- .NET
- [PowerShell](/docs/pswriteoffice/install/) `Install-Module PSWriteOffice`

**Target frameworks**

netstandard2.0, net10.0, net472

**APIs**

- [`OfficeLength`](/api/core/officeimo-officelength/)
- [`VisioStencilPackageCatalog`](/api/visio/officeimo-visio-stencils-visiostencilpackagecatalog/)
- [`VisioStencils`](/api/visio/officeimo-visio-stencils-visiostencils/)
- [`VisioDocument`](/api/visio/officeimo-visio-visiodocument/)
- [`VisioPage`](/api/visio/officeimo-visio-visiopage/)
- [`VisioShape`](/api/visio/officeimo-visio-visioshape/)
- [`VisioSide`](/api/visio/officeimo-visio-visioside/)
- [`VisioStencilShape`](/api/visio/officeimo-visio-stencils-visiostencilshape/)
- [`ConnectorKind`](/api/visio/officeimo-visio-connectorkind/)
- [`VisioStencilCatalog`](/api/visio/officeimo-visio-stencils-visiostencilcatalog/)
- [`VisioStencilPackageLoadOptions`](/api/visio/officeimo-visio-stencils-visiostencilpackageloadoptions/)

**Cmdlets**

- [`New-OfficeVisio`](/api/powershell/new-officevisio/)
- [`Import-OfficeVisioStencilCatalog`](/api/powershell/import-officevisiostencilcatalog/)
- [`Add-OfficeVisioStencilShape`](/api/powershell/add-officevisiostencilshape/)
- [`Add-OfficeVisioConnector`](/api/powershell/add-officevisioconnector/)
- [`Find-OfficeVisioStencil`](/api/powershell/find-officevisiostencil/)
- [`Export-OfficeVisioStencilPreviewGallery`](/api/powershell/export-officevisiostencilpreviewgallery/)

**Limits**

OfficeIMO does not bundle third-party stencil packs or infer their license; license and attribution are metadata you supply. [OfficeIMO.Visio support matrix](/compatibility/#package-visio)

**Verified**

Examples compiled against the source on 2026-11-14

**Data**

- [OfficeIMO.Visio API index](/api/visio/index.json)
- [PSWriteOffice command catalog](/data/powershell/commands.json)
- [Capability catalog (JSON)](/data/capabilities.json)

`VisioStencils` (namespace `OfficeIMO.Visio.Stencils`) has built-in catalogs such as `Flowchart`, `Network`, and `BasicShapes`. `VisioStencilPackageCatalog` loads masters from `.vssx` or `.vstx` packages you supply. A placed shape keeps its link to the master, so the diagram stays editable and can be migrated later.

## Place shapes from a built-in catalog

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Visio;
using OfficeIMO.Visio.Stencils;

using VisioDocument document = VisioDocument.Create("network.vsdx");
VisioPage page = document.AddPage("Network", OfficeLength.Inches(11), OfficeLength.Inches(8.5));

VisioShape server = page.AddStencilShape(VisioStencils.Network.Get("server"), "server",
    OfficeLength.Inches(2), OfficeLength.Inches(4), "Application server");
VisioShape database = page.AddStencilShape(VisioStencils.Network.Get("database"), "database",
    OfficeLength.Inches(6), OfficeLength.Inches(4), "Orders database");

page.AddConnector(server, database, ConnectorKind.RightAngle, VisioSide.Right, VisioSide.Left);

document.Save();
```

### PowerShell

```powershell
New-OfficeVisio -Path .\network.vsdx -UseMastersByDefault {
    Import-OfficeVisioStencilCatalog -BuiltIn Network -Name Net -Default
    Add-OfficeVisioStencilShape -Catalog Net -Stencil server -Key server -Text 'Application server' -X 2 -Y 4
    Add-OfficeVisioStencilShape -Catalog Net -Stencil database -Key database -Text 'Orders database' -X 6 -Y 4
    Add-OfficeVisioConnector -From server -To database -Kind RightAngle
}
```

## Find a shape in a catalog

### C#

```csharp
using OfficeIMO.Visio.Stencils;

foreach (VisioStencilShape shape in VisioStencils.Flowchart.Shapes.Take(10)) {
    Console.WriteLine($"{shape.Id}: {shape.Name}");
}

if (VisioStencils.Flowchart.TryGet("decision", out VisioStencilShape? decision)) {
    Console.WriteLine(decision!.Name);
}
```

### PowerShell

```powershell
Find-OfficeVisioStencil -BuiltIn Flowchart -Query process -First 5
```

## Load a VSSX or VSTX stencil pack

Use a stencil pack only when your application is allowed to use it. `SourceLicense` and `SourceAttribution` are carried into shapes, catalogs, and manifests; OfficeIMO does not check them. Masters that OfficeIMO cannot author stay marked as unsupported when `IncludeUnsupportedMasters` is set.

### C#

```csharp
using OfficeIMO;
using OfficeIMO.Visio;
using OfficeIMO.Visio.Stencils;

VisioStencilCatalog catalog = VisioStencilPackageCatalog.Load("MyShapes.vssx", new VisioStencilPackageLoadOptions {
    CatalogName = "My Shapes",
    SourceLicense = "License identifier or notice for this pack",
    SourceAttribution = "Required attribution",
    IncludeUnsupportedMasters = true
});

Console.WriteLine($"{catalog.Shapes.Count} masters in {catalog.Name}");

using VisioDocument document = VisioDocument.Create("custom.vsdx");
VisioPage page = document.AddPage("Custom", OfficeLength.Inches(11), OfficeLength.Inches(8.5));
page.AddStencilShape(catalog.Shapes[0], "first", OfficeLength.Inches(3), OfficeLength.Inches(4), catalog.Shapes[0].Name);
document.Save();
```

On Windows, `VisioStencilPackageCatalog.DiscoverInstalledVisioPackages()` lists the stencil packs of an installed Visio, and `LoadMany` loads several packs into one catalog.

### PowerShell

```powershell
$catalog = Import-OfficeVisioStencilCatalog -Path .\MyShapes.vssx -CatalogName 'My Shapes' -IncludeUnsupportedMasters
Find-OfficeVisioStencil -Catalog $catalog -First 10
```

## Preview a stencil pack

### PowerShell

Write an HTML gallery of every master in a pack:

```powershell
Export-OfficeVisioStencilPreviewGallery -Path .\MyShapes.vssx -OutputDirectory .\StencilGallery -Title 'My shapes'
```

## Keep stencil mappings stable

1. Look up masters by a stable catalog key, not by display order.
2. Record the source stencil and the master you expect.
3. Keep application data separate from shape placement.
4. Validate the generated VSDX after upgrading a stencil pack.

<!-- PowerForge markdown source sha256:A7917F7E05802C15B8F9A3B617AF25FA4DAE0CA0045B9CA777BE446FFEB89822; title=True -->

<!-- PowerForge markdown artifact sha256:8BCBC5E654A5788FAAC967DE90CF762937568B36D17BF19C283FC8A9F224F9A4 -->
