VisioAutomation icon indicating copy to clipboard operation
VisioAutomation copied to clipboard

problem creating shape

Open mythrandir52 opened this issue 6 years ago • 5 comments

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 `

mythrandir52 avatar Jun 18 '19 00:06 mythrandir52

i added as a test

$stencil_comp = Open-VisioDocument "Computers and Monitors.vss" get-visiomaster -Name * $stencil_comp

and it came back with a list of the objects.

i get nothing back from

$grp = Open-VisioDocument "actdir_u.vstx" get-visiomaster -Name * $grp

mythrandir52 avatar Jun 18 '19 18:06 mythrandir52

Try changing ...

get-visiomaster -Name * -document $stencil_comp

guldmann0211 avatar Feb 15 '24 11:02 guldmann0211

However when trying to place it...

PS C:\WINDOWS\system32> $shapes = New-VisioShape -Master $g -Points 2.2,6.8 New-VisioShape : Cannot bind parameter 'Points'. Cannot convert the "2,2" value of type "System.Double" to type "VisioAutomation.Geometry.Point". At line:1 char:45

  • $shapes = New-VisioShape -Master $g -Points 2.2,6.8
  •                                         ~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [New-VisioShape], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VisioPowerShell.Commands.VisioShape.NewVisioShape

guldmann0211 avatar Feb 15 '24 11:02 guldmann0211

Tried various variations with the same lack of luck..

$shapes = New-VisioShape -Master $g -Points @(2.2,6.8)

or more elaborate

$point1 = New-Object VisioAutomation.Geometry.Point 2.0, 6.0 $point2 = New-Object VisioAutomation.Geometry.Point 2.0, 8.0 $points = @($point1,$point2)

Assuming $pc_master is correctly set

$shapes = New-VisioShape -Masters $pc_master -Points $points

guldmann0211 avatar Feb 15 '24 11:02 guldmann0211

Sorry for the late response @guldmann0211. Will take a look very, very soon.

saveenr avatar Apr 05 '24 04:04 saveenr