saveenr / visioautomation Goto Github PK
View Code? Open in Web Editor NEWAutomate Microsoft Visio with .NET
License: Other
Automate Microsoft Visio with .NET
License: Other
i am having an issue creating a shape from the "Active Directory US" template. It can seem to find the shape listed. so the object is coming back as null. I know i am doing something probably simple wrong. Can someone help please. Is there an easy way to masters for a given visio doc.
The code open visio, create the page and then loads the active direct template but i can seem to grab the group or other objects from the shape template.
Mycode:
`
Import-Module Visio
$app= New-VisioApplication
$doc = New-VisioDocument
$grp = Open-VisioDocument "actdir_u.vstx"
$g = get-visiomaster -Name "Group" $grp
$shapes = New-VisioShape -Master $g -Points 2.2,6.8
`
XML looks like this:
<shape id="n3" label="Groups" stencil="ADO_u.vss" master="Organizational Unit" url="" />
<shape id="n4" label="Syngo" stencil="ADO_u.vss" master="Organizational Unit" url="" />
<shape id="n5" label="AP&S" stencil="ADO_u.vss" master="Organizational Unit" url="" />
I get the following error when the XML has the "&" symbol in the label:
Import-visiomodel : '"' is an unexpected token. The expected token is ';'. Line 12, position 27.
At line:2 char:10
+ $model = Import-visiomodel -filename $filename
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-VisioModel], XmlException
+ FullyQualifiedErrorId : System.Xml.XmlException,VisioPowerShell.Commands.VisioModel.ImportVisioModel
Hi there! I saw that you were working with automatic-graph-layout. Have you been able to draw a diagram in Visio from it?
Trying to install the Visio Module, but it is failing
PS C:\Users\xxx> Install-Module Visio -Scope CurrentUser
PackageManagement\Install-Package : Access is denied
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.1.3\PSModule.psm1:9508 char:21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With -verbose -debug:
PS C:\Users\xxx> Install-Module Visio -Scope CurrentUser -verbose -debug
DEBUG: 00:00:00.0000003 Calling New() : MethodName = 'GetDynamicOptions'
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
DEBUG: 00:00:00.0000230 Verbose: True
DEBUG: 00:00:00.0000347 Debug: True
DEBUG: 00:00:00.0000449 Name: Visio
DEBUG: 00:00:00.0015658 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0023632 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0034182 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0063127 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0063309 Verbose: True
DEBUG: 00:00:00.0063422 Debug: True
DEBUG: 00:00:00.0063531 Name: Visio
DEBUG: 00:00:00.0070105 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1
DEBUG: 00:00:00.0077691 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0094259 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0121992 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0122170 Verbose: True
DEBUG: 00:00:00.0122283 Debug: True
DEBUG: 00:00:00.0122389 Name: Visio
DEBUG: 00:00:00.0128721 INVOKING PowerShell Fn Get-DynamicOptions with args Package that has length 1
DEBUG: 00:00:00.0139236 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0171723 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0199551 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0199725 Verbose: True
DEBUG: 00:00:00.0199842 Debug: True
DEBUG: 00:00:00.0199948 Name: Visio
DEBUG: 00:00:00.0206280 INVOKING PowerShell Fn Get-DynamicOptions with args Install that has length 1
DEBUG: 00:00:00.0213567 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0238548 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:07.7024550 Calling SearchForPackages. Name='Visio'
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
DEBUG: 00:00:07.7034971 PackageProvider::FindPackage with name Visio
DEBUG: 00:00:07.7092092 Calling SearchForPackages After Select 1
DEBUG: 00:00:07.7238129 Calling New() : MethodName = 'FindPackage'
DEBUG: 00:00:07.7340321 ProviderName: PowerShellGet
DEBUG: 00:00:07.7351022 Type: Module
DEBUG: 00:00:07.7450586 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:07.7547353 Debug: True
DEBUG: 00:00:07.7559624 Scope: CurrentUser
DEBUG: 00:00:07.7657399 Verbose: True
DEBUG: 00:00:07.7669821 Name: Visio
DEBUG: 00:00:07.7766777 INVOKING PowerShell Fn Find-Package with args System.String[], , , that has length 4
DEBUG: 00:00:07.7794948 In PowerShellGet Provider - 'Find-Package'.
DEBUG: 00:00:07.7876717 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:07.7914826 OPTION: Type => Module
DEBUG: 00:00:07.7982466 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:07.7997158 OPTION: Debug => True
DEBUG: 00:00:07.8082087 OPTION: Scope => CurrentUser
DEBUG: 00:00:07.8093547 OPTION: Verbose => True
DEBUG: 00:00:07.8207875 OPTION: Name => Visio
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
DEBUG: 00:00:07.8432618 PackageProvider::FindPackage with name Visio
DEBUG: 00:00:07.8467212 Calling 'NuGet'::'FindPackage' - name='Visio', requiredVersion='',minimumVersion='', maximumVersion='''.
DEBUG: 00:00:07.8567226 Iterating 'Visio'.
DEBUG: 00:00:07.8581227 There are '0' registered sources in 'NuGet' provider.
DEBUG: 00:00:07.8663996 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider.
DEBUG: 00:00:07.8687448 Source 'https://www.powershellgallery.com/api/v2' is validated.
DEBUG: 00:00:07.8766612 Calling 'NuGetRequest'::'GetPackageById', 'Visio'.
DEBUG: 00:00:07.8910206 Calling 'NuGetPackageRepository'::'FindPackagesById', 'Visio'.
DEBUG: 00:00:07.8939121 Calling 'NuGetPackageFeed2'::'FindPackage', 'Visio'.
DEBUG: 00:00:07.9030477 Calling 'NuGetClient'::'FindPackage'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'' for ''.
DEBUG: 00:00:07.9127885 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'&$skip=0&$top=40'.
DEBUG: 00:00:08.0366529 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'&$skip=0&$top=40'.
DEBUG: 00:00:08.0407753 '34' packages received in the last request.
DEBUG: 00:00:08.0435037 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'&$skip=0&$top=40'.
DEBUG: 00:00:08.0582626 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'&$skip=0&$top=40'.
DEBUG: 00:00:08.0612557 '34' packages received in the last request.
VERBOSE: Total package yield:'1' for the specified package 'Visio'.
DEBUG: 00:00:08.0741052 Completed iterating for 'Visio'.
DEBUG: 00:00:08.0846189 Done calling powershell «Find-Package» «PSModule»
DEBUG: 00:00:08.0964889 Calling New() : MethodName = 'GetInstalledPackages'
DEBUG: 00:00:08.1005759 ProviderName: PowerShellGet
DEBUG: 00:00:08.1027606 Type: Module
DEBUG: 00:00:08.1040187 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:08.1149606 Debug: True
DEBUG: 00:00:08.1165453 Scope: CurrentUser
DEBUG: 00:00:08.1251749 Verbose: True
DEBUG: 00:00:08.1264961 Name: Visio
DEBUG: 00:00:08.1362097 INVOKING PowerShell Fn Get-InstalledPackage with args Visio, 3.4.0, , that has length 4
DEBUG: 00:00:08.1386342 In PowerShellGet Provider - 'Get-InstalledPackage'.
DEBUG: 00:00:08.1465955 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:08.1531597 OPTION: Type => Module
DEBUG: 00:00:08.1554607 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:08.1566856 OPTION: Debug => True
DEBUG: 00:00:08.1659446 OPTION: Scope => CurrentUser
DEBUG: 00:00:08.1673262 OPTION: Verbose => True
DEBUG: 00:00:08.1768348 OPTION: Name => Visio
DEBUG: 00:00:08.2301591 PowerShell Script 'PSModule' Function 'Get-InstalledPackage' returns null.
DEBUG: 00:00:08.2352398 Done calling powershell «Get-InstalledPackage» «PSModule»
Confirm
Are you sure you want to perform this action?
Performing the operation "Install-Module" on target "Version '3.4.0' of module 'Visio'".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a
DEBUG: 00:00:31.4421030 Calling New() : MethodName = 'InstallPackage'
DEBUG: 00:00:31.4445123 ProviderName: PowerShellGet
DEBUG: 00:00:31.4458916 Type: Module
DEBUG: 00:00:31.4485589 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:31.4498649 Debug: True
DEBUG: 00:00:31.4608907 Scope: CurrentUser
DEBUG: 00:00:31.4668334 Verbose: True
DEBUG: 00:00:31.4711794 Name: Visio
DEBUG: 00:00:31.4790047 INVOKING PowerShell Fn Install-Package with args NuGet|Visio|3.4.0|https://www.powershellgallery.com/api/v2|Module that has length 1
DEBUG: 00:00:31.4827035 In PowerShellGet Provider - 'Install-Package'.
DEBUG: 00:00:31.4896657 In PowerShellGet Provider - 'Install-PackageUtility'.
DEBUG: 00:00:31.4909593 The FastPackageReference is 'NuGet|Visio|3.4.0|https://www.powershellgallery.com/api/v2|Module'.
DEBUG: 00:00:31.5034486 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:31.5137490 OPTION: Type => Module
DEBUG: 00:00:31.5151581 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:31.5240052 OPTION: Debug => True
DEBUG: 00:00:31.5251550 OPTION: Scope => CurrentUser
DEBUG: 00:00:31.5406154 OPTION: Verbose => True
DEBUG: 00:00:31.5506183 OPTION: Name => Visio
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\516412\Documents\WindowsPowerShell\Modules'.
DEBUG: 00:00:31.5637751 ArtifactType is Module
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'Visio' with version '3.4.0' from the repository 'https://www.powershellgallery.com/api/v2'.
DEBUG: 00:00:31.5977971 Calling 'NuGet'::'InstallPackage',
'$aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\VmlzaW8=\My40LjA=\aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\cG93ZXJzaGVsbGdldA=='.
DEBUG: 00:00:31.6006078 Calling 'NuGetRequest'::'GetPackageByFastpath',
'$aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\VmlzaW8=\My40LjA=\aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\cG93ZXJzaGVsbGdldA=='.
DEBUG: 00:00:31.6054608 Calling 'NuGetRequest'::'ResolvePackageSource', 'https://www.powershellgallery.com/api/v2'.
DEBUG: 00:00:31.6070274 Calling 'NuGetRequest'::'FindRegisteredSource', 'https://www.powershellgallery.com/api/v2'.
DEBUG: 00:00:31.6131223 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider.
DEBUG: 00:00:31.6324685 Calling 'NuGetPackageRepository'::'FindPackage', 'Visio'.
DEBUG: 00:00:31.6359747 Calling 'NuGetPackageFeed2'::'FindPackage', 'Visio'.
DEBUG: 00:00:31.6472628 Calling 'NuGetClient'::'FindPackage'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'' for ''.
DEBUG: 00:00:31.6583970 Downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'&$skip=0&$top=40'.
DEBUG: 00:00:31.7431054 Completed downloading 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='Visio'&$skip=0&$top=40'.
DEBUG: 00:00:31.7544109 '34' packages received in the last request.
DEBUG: 00:00:31.7628042 'Package version' is '3.4.0'.
DEBUG: 00:00:31.7651713 'Request's Destination' is 'C:\Users\516412\AppData\Local\Temp\1774301534'.
DEBUG: 00:00:31.7743748 Calling 'NuGetPackageRepository'::'InstallPackage'.
DEBUG: 00:00:31.7757575 Calling 'NuGetFilesFeed2'::'InstallPackage'.
DEBUG: 00:00:31.7846443 Calling 'NuGetFilesFeed2'::'InstallPackage',
'$aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\VmlzaW8=\My40LjA=\aHR0cHM6Ly93d3cucG93ZXJzaGVsbGdhbGxlcnkuY29tL2FwaS92Mg==\cG93ZXJzaGVsbGdldA=='.
DEBUG: 00:00:31.7952554 Calling 'NuGetClient'::'GetPackageDependencies'.
DEBUG: 00:00:31.7986419 Returning the call 'NuGetClient'::'GetPackageDependencies'.
DEBUG: 00:00:31.8206511 Calling 'NuGetClient'::'InstallPackage'.
VERBOSE: InstallPackage' - name='Visio', version='3.4.0',destination='C:\Users\516412\AppData\Local\Temp\1774301534'
VERBOSE: DownloadPackage' - name='Visio', version='3.4.0',destination='C:\Users\516412\AppData\Local\Temp\1774301534\Visio.3.4.0\Visio.3.4.0.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/Visio/3.4.0'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/Visio/3.4.0'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/Visio/3.4.0'.
VERBOSE: Completed downloading 'Visio'.
DEBUG: 00:00:32.3378777 Calling 'NuGetClient'::'InstallPackageLocal'.
VERBOSE: InstallPackageLocal' - name='Visio', version='3.4.0',destination='C:\Users\516412\AppData\Local\Temp\1774301534'
DEBUG: 00:00:32.3705038 C:\Users\516412\AppData\Local\Temp\1774301534\Visio.3.4.0\Visio.3.4.0.nupkg
DEBUG: 00:00:32.6440508 Returning the call 'NuGetClient'::'InstallPackageLocal'.
DEBUG: 00:00:32.6765201 Returning the call 'NuGetClient'::'InstallSinglePackage'.
DEBUG: 00:00:32.6779481 Returning the call 'NuGetFilesFeed2'::'InstallPackage'.
DEBUG: 00:00:32.7083332 PowerShell Script 'PSModule' Function 'Install-Package' returns null.
Confirm
Access is denied
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
PackageManagement\Install-Package : Access is denied
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.1.3\PSModule.psm1:9508 char:21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PS C:\Users\516412>
It appears Get-VisioScriptingClient is missing from version 4.3 and up code. Also missing is the MSAGLLayoutOptions as spelled out in: $options = New-Object VisioAutomation.Models.Layouts.DirectedGraph.MSAGLLayoutOptions
$sc = Get-VisioScriptingClient
$sc.Assemblies | %{ Add-Type -Path $_ }
Get-VisioScriptingClient : The term 'Get-VisioScriptingClient' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:7
+ $sc = Get-VisioScriptingClient
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-VisioScriptingClient:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Is it possible to change the graph layout or graph direction when using the directedgraph XML? My hope would be to change the direction from LeftToRight and to change the connectors from curved to straight. I attempted to do this via the following code but it always draws it the same way. Note: the code below does not have the connectors from curved to straight as I couldn't find any documentation on the internet for that.
<directedgraph GraphDirection="LeftToRight" Layout="Sugiyama">
<page>
<renderoptions
usedynamicconnectors="true"
scalingfactor="20" />
<shapes>
..............
I am attempting to set custom properties when building shapes via the "directed graph from code" example. Note: the shapes don't exist yet so I can't use set-visiocustomproperty function. I have tried the code below plus multiple variations:
This code will create the "DisplayName1234" custom property but the value is always 0.
$g1 = $d.AddShape("g1", "webserver", "Servers.vss", "Server")
$cpDic = New-Object VisioAutomation.Shapes.CustomPropertyDictionary
$cpCellsName = New-Object VisioAutomation.Shapes.CustomPropertyCells
$cpCellsName.Value = "testVal"
$cpDic.Add("DisplayName1234",$cpCellsName)
$g1.CustomProperties = $cpDic
I've also tried:
$cpCellsName = New-Object VisioAutomation.Shapes.CustomPropertyCells
$cpCellsName.Value = "testVal"
[VisioAutomation.Shapes.CustomPropertyHelper]::Set($g1.VisioShape,"displayname",$cpCellsName)
but it results in:
[VisioAutomation.Shapes.CustomPropertyHelper]::Set($g1.VisioShape,"DisplayName",$cpCellsName)
Exception calling "Set" with "3" argument(s): "
#NAME?"
At line:1 char:1
+ [VisioAutomation.Shapes.CustomPropertyHelper]::Set($g1.VisioShape,"Di ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : COMException
Hi,
Im trying to use the poweshell module to create a directed graph in Visio 2013. I can run:
New-VisioApplication
New-VisioDocument
Import-VisioModel -Verbose
I can see some output stating
VERBOSE: Root element name =orgchart
VERBOSE: Loading as an Org Chart
VERBOSE: Walking XML
VERBOSE: Loading shape: 0 Akuma
VERBOSE: Loading shape: 1 Ryu 0
VERBOSE: Loading shape: 2 Ken 0
VERBOSE: Loading shape: 3 Chun-Li 2
VERBOSE: Finished Walking XML
VERBOSE: Finished Creating OrgChart model
but nothing is rendered in Visio?
Am I doing something wrong?
When both Size and Cells are set, the size value doesn't seem to take any effect.
VisioAutomation.Models.Layouts.DirectedGraph.Shape shape = AddShape();
shape.Size = new Size(1.25, 0.25);
shape.Cells = new VisioAutomation.Models.Dom.ShapeCells();
shape.Cells.FillForeground = "rgb(0,255,0)";
shape.Cells.FillPattern = 1;
The resulting shape has default size (2.25, 1.5) instead of the specified size.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.