Skip to content

Commit

Permalink
Merge pull request #62 from MikeShepard/Develop
Browse files Browse the repository at this point in the history
Added support for VisioSettings (Import-VisioSettings) and included a…
  • Loading branch information
MikeShepard committed Jun 15, 2016
2 parents ccb678a + 9825821 commit a70177f
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Examples/DiagramSettings.psd1
@@ -0,0 +1,15 @@
@{
StencilPaths='c:\temp'

Stencils=@{Containers='C:\temp\MyContainers.vssx';
Servers='SERVER_U.vssx'}

Shapes=@{WebServer='Servers','Web Server';
DBServer='Servers','Database Server'
}
Containers=@{Domain='Containers','Domain'
}

Connectors=@{SQL=@{Color='Red';Arrow=$true}}

}
21 changes: 21 additions & 0 deletions Examples/VisioSettingsExample.ps1
@@ -0,0 +1,21 @@
Import-Module VisioBot3000 -Force


#start Visio and create a new document
New-VisioApplication
New-VisioDocument C:\temp\TestVisioPrimitives.vsdx

$doc=Get-VisioDocument
Set-VisioDiagramServices -Document $doc -Value $vis.ServiceAll

#adjust path to match the location you put the setting file.
Import-VisioSettings -path C:\Users\mike\Documents\WindowsPowerShell\modules\VisioBot3000\Examples\DiagramSettings.psd1

#draw a container with two items in it
Domain MyDomain {
WebServer PrimaryServer
DBServer SQL01
}

#add a connector
SQL -from PrimaryServer -To SQL01
55 changes: 55 additions & 0 deletions VisioSettings.ps1
@@ -0,0 +1,55 @@
<#
.SYNOPSIS
Reads a psd1 file with settings for the current diagram.
.DESCRIPTION
Reads a psd1 file with settings for the current diagram. Should be called after a diagram has been opened or created.
Currently supported sections are:
StenciPaths - list of paths to be added to the stencilpath
Stencils - hashtable with name=nickname of stencil, value=filename to stencil
Shapes - hashtable with name=nickname, value=array with stencilname and mastername
Containers - hashtable with name=nickname, value=array with stencilname and mastername
Connectors - hashtable with name=nickname, value=hashtable of parameters splatted to register-visioconnector
.PARAMETER Path
The path to the psd1 file. Must be a full path, not just a filename.
.INPUTS
You cannot pipe anything to Import-VisioSettings
.OUTPUTS
None
.EXAMPLE
Import-VisioSettings c:\Config\DepartmentalDiagramSettings.psd1
#>
function Import-VisioSettings{
[CmdletBinding()]
Param([string]$path)
$dir=Split-Path -Path $path -Parent
$file=split-path -Path $path -leaf
$settings=Import-LocalizedData -FileName $file -BaseDirectory $dir
if($settings.StencilPaths){
$settings.StencilPaths | foreach-object {Add-StencilSearchPath -Path $_}
}

if($settings.Stencils){
$Settings.Stencils.GetEnumerator() | foreach{Register-VisioStencil -Name $_.Key -Path $_.Value}
}

if($settings.Shapes){
$Settings.Shapes.GetEnumerator() | foreach{Register-VisioShape -Name $_.Key -From $_.Value[0] -MasterName $_.Value[1]}
}
if($settings.Containers){
$Settings.Containers.GetEnumerator() | foreach{Register-VisioContainer -Name $_.Key -From $_.Value[0] -MasterName $_.Value[1]}
}
if($settings.Connectors){

$Settings.Connectors.GetEnumerator() | foreach{$options=$_.Value;Register-VisioConnector -Name $_.Key @options}
}


}

0 comments on commit a70177f

Please sign in to comment.