Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to automate network diagrams and I'm having trouble getting rid of the label of the cloud shape. When I try to get rid of the -Label parameter, the cloud will not be drawn. I know that I can manually delete the label but is there a way to draw the cloud without using the -Label parameter? I've provided my code down below:

#Import-Module Visio
Import-Module VisioBot3000 -Force

## Variables
$Username = $env:USERNAME
$set_x = 2.25
$set_y = 5.5
## Empty CE Router List
$CE_Router_List = @()
## Empty Site Address list
$Site_Address = @()
## Empty arrows list
$arrows = @()
$Gold_Car_List = @()


$Servers = Read-Host 'How many routers do you have?'

## Opens the Visio application
New-VisioApplication
## Opens the Verizon network diagram template
Open-VisioDocument
## Creates a new Visio Page
New-VisioPage

## Register the network shapes stencil (with US measurements)
$CloudStencil = Register-VisioStencil -Name NetworkLocations -Path 'NETLOC_U.VSSX'
$PESwitchStencil = Register-VisioStencil -Name NetworkSymbols -Path 'NETSYM_U.VSSX'
$GoldCarStencil = Register-VisioStencil -Name BasicShapes -Path 'BASIC_U.VSSX'

## Register the PE switch shape
$PE_Switch_Shape = Register-VisioShape -Name 'ATM switch' -StencilName NetworkSymbols -MasterName 'ATM switch'
## Register the CE Router shape
$CE_Router_Shape = Register-VisioShape -Name Router -StencilName NetworkSymbols -MasterName Router
$Cloud_Shape = Register-VisioShape -Name Cloud -StencilName NetworkLocations -MasterName Cloud
## Register the Gold CAR
$Gold_Car = Register-VisioShape -Name Can -Stencil BasicShapes -MasterName Can

## Creates the initial Cloud
$Cloud = New-VisioShape Cloud -Label Cloud -x 5.6296 -y 4.445
## Adjusts the width of the Cloud
$Cloud_Width = $Cloud.CellsU('Width').FormulaU = '3 in'
## Adjusts the height of the Cloud
$Cloud_Height = $Cloud.CellsU('Height').FormulaU = '1.89 in'

<#
.SYNOPSIS
    Sets the color of a shape
.DESCRIPTION
    Sets the color of a shape and subshapes to a given color
.EXAMPLE
    $shape= add-visioshape -stencil BasicShapes -name Square
    Set-ShapeColor -shape $shape -color Red
.INPUTS
    You cannot pipe any objects into Set-ShapeColor
.OUTPUTS
    None
.PARAMETER Shape
    The shape to apply the color to
.PARAMETER Color
    The color you want the shape to be
    #>
function Set-VisioShapeColor {
    [CmdletBinding()]
    Param($Shape,
        [System.Drawing.Color]$Color,
        [ValidateSet('FillForegnd', 'FillBkgnd')]$FillType = 'FillBkgnd'
        )
    $ColorFormula = "=THEMEGUARD(rgb($($Color.R),$($Color.G),$($Color.B)))"


    $shape.CellsU($fillType).FormulaForce = $ColorFormula
    $shape.CellsU('FillGradientEnabled').FormulaForce = 'FALSE'
    $shape.CellsU('FillPattern').FormulaForce = '1'
    $shape.shapes | foreach-object {
        $_.CellsU('FillGradientEnabled').FormulaForce = 'FALSE'
        $_.CellsU($fillType).FormulaForce = $colorFormula 
    }
}

## Set the Cloud color to gray
Set-VisioShapeColor -shape $PIP_Cloud -color Gray

##Creates all of the CE Routers
$num = 0
for ($initial = 1; $initial -le $Servers; $initial++) {
    $CE_Router = New-VisioShape -Master Router -Label '123 Ashwood Drive, Los Angeles, California' -x $set_x  -y $set_y -Name MyRouter
    $CE_Router.CellsU('Width').FormulaU = '0.20 in'
    $CE_Router.CellsU('Height').FormulaU = '0.15 in'
    $CE_Router.CellsU("Char.Size").FormulaU="7 pt"
    $CE_Router_List += $CE_Router
    $num++
}

## The arrows that connect from the Cloud to the CE Router.
Foreach($element in $CE_Router_List)   {
   $arrows+=New-VisioConnector -From $Cloud -To $element -name SQLConnection -Arrow -color Red
}

$page=Get-VisioPage
$Page.PageSheet.CellsSRC(1,24,8).FormulaForceU="6"
$Page.PageSheet.CellsSRC(1,24,9).FormulaForceU="16"
$Page.Layout()
$Page.ResizeToFitContents()

$sel = New-VisioSelection -Objects ($CE_Router_List.Name+$arrows.Name+'Cloud') -Visible
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
143 views
Welcome To Ask or Share your Answers For Others

1 Answer

The syntax you want comes from:

https://www.powershellstation.com/2016/04/29/introducing-visiobot3000-part-2-superman/

So the syntax for the line of code to drop a shape on a page is:

New-VisioShape -master WebServer -name PrimaryServer -x 5 -y 5

Your code isn't following this format.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...