VisioPowerShell
Version 4.5
Version 4.5
  • Introduction
  • Quick start
  • Links
  • Basics
    • Geometry primitves
    • Context-sensitivity
    • Drop shape masters
    • Format shapes with cells
    • Draw basic shapes
    • Create pages
    • Enumerate shapes
    • Bound Visio application
    • Close Visio applications
    • List cmdlets
    • List of all cmdlets
    • Get help for a cmdlet
    • Tips
    • Verbose logging
  • Automatic diagrams
    • Org charts from XML
    • Directed graphs from code
    • Directed graphs from XML
      • Sample Directed Graph XML 1
      • Sample Directed Graph XML 2
      • Sample Directed Graph XML 3
      • Sample Directed Graph XML 4
  • Samples
    • Draw grid
    • Draw fill patterns - slow
    • Draw fill patterns - fast
    • Countdown days
  • Installation
    • Install VisioPS
    • Uninstall VisioPS
    • Detect if VisioPS is installed
  • Technical notes
    • Visio
      • Visio version compatibility
      • Create a new Visio application COM object
    • PowerShell
      • Install PowerShell
      • Detect installed PowerShell version
      • PowerShell version compatibility
      • Use PowerShell 2 with .NET Framework 2.0
    • VisioClient
    • Use VisioAutomation
  • Cmdlets
    • Documents
      • Close-VisioDocument
      • Get-VisioDocument
      • New-VisioDocument
      • Open-VisioDocument
      • Save-VisioDocument
    • Container
    • Custom properties
      • Get-VisioCustomProperty
      • Remove-VisioCustomProperty
      • Set-VisioCustomProperty
      • Examples
    • Hyperlinks
      • Get-VisioHyperlink
      • New-VisioHyperlink
      • Remove-VisioHyperlink
    • Master
      • Get-VisioMaster
    • Pages
      • Copy-VisioPage [TBD]
      • Export-VisioPage
      • Format-VisioPage
      • Get-VisioPage
      • Measure-VisioPage
      • New-VisioPage
      • Remove-VisioPage
      • Select-VisioPage [TBD]
    • PageCells
    • Shapes
      • Connect-VisioShape
      • Copy-VisioShape
      • Export-VisioShape
      • Format-VisioShape
      • Get-VisioShape
      • Join-VisioShape
      • Lock-VisioShape
      • Select-VisioShape
      • Select-VisioShape Invert
      • Select-VisioShape -None
      • Split-VisioShape
      • Test-VisioShape
      • Unlock-VisioShape
      • Examples of Join-VisioShape and Split-VisioShape
    • ShapeCells
      • Set-VisioShapeCells for text
      • Shape cells
    • User-defined cells
      • Get-UserDefinedCell
      • Set-VisioUserDefinedCell
      • Remove-UserDefinedCell
    • Selection
      • Export-VisioSelection
      • Test-VisioSelectedShapes
    • Text
      • Get-VisioText [TBD]
      • Set-VisioText
    • VisioApplication
      • Close-VisioApplication
      • Get-VisioApplication
      • New-VisioApplication
      • Out-VisioApplication
      • Test-VisioApplication
      • Undo-VisioApplication
      • Redo-VisioApplication
    • Windows
      • Format-VisioWindow
  • Developer Info
    • Release history
    • Publis to PowerShell Gallery
    • Debug with Visual Studio
Powered by GitBook
On this page
  1. Basics

Format shapes with cells

PreviousDrop shape mastersNextDraw basic shapes

Last updated 3 years ago

Formatting the Shapes that were dropped

The example below sets all the shapes to have a consistent width, height, fill color, and line weight.

$shape_cells = New-VisioShapeCells
$shape_cells.XFormWidth = 2
$shape_cells.XFormHeight = 4
$shape_cells.FillForeground = "rgb(255,0,0)"
$shape_cells.LineWeight = "5 pt"

$basic_u = Open-VisioDocument "basic_u.vss"
$masters = Get-VisioMaster -Name "Rectangle","Triangle","Circle"  -Document $basic_u
$points = @(
    New-VisioPoint 4 5
    New-VisioPoint 6 1
    New-VisioPoint 0 0
    )
$shape = New-VisioShape -Master $masters -Position $points -Cells $shape_cells

If you want to format each shape separately, that is possible also by passing in multiple shape cells objects



$shape_cells1 = New-VisioShapeCells
$shape_cells2 = New-VisioShapeCells
$shape_cells3 = New-VisioShapeCells

$shape_cells = @( 
    $shape_cells1, $shape_cells2, $shape_cells3
)

$shape_cells1.XFormWidth = 2
$shape_cells1.FillForeground = "rgb(255,255,0)"
$shape_cells2.XFormHeight = 4
$shape_cells2.FillForeground = "rgb(0,0,255)"
$shape_cells3.FillForeground = "rgb(255,0,0)"
$shape_cells3.LineWeight = "5 pt"

$basic_u = Open-VisioDocument "basic_u.vss"
$masters = Get-VisioMaster -Name "Rectangle","Triangle","Circle"  -Document $basic_u
$points = @(
    New-VisioPoint 4 5
    New-VisioPoint 6 1
    New-VisioPoint 0 0
    )
$shape = New-VisioShape -Master $masters -Position $points -Cells $shape_cells

Many common formatting options are available in the ShapeCells object returned by New-VisioShapeCells. To find see all the properties use the following command

$shape_cells = New-VisioShapeCells
$shape_cells | select *