Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set custom properties using "directed graph from code" #117

Open
tcox8 opened this issue Dec 2, 2021 · 0 comments
Open

How to set custom properties using "directed graph from code" #117

tcox8 opened this issue Dec 2, 2021 · 0 comments

Comments

@tcox8
Copy link

tcox8 commented Dec 2, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant