saveenr / VisioAutomation

Automate Microsoft Visio with .NET
Other
99 stars 43 forks source link

problem creating shape #102

Open mythrandir52 opened 5 years ago

mythrandir52 commented 5 years ago

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 commented 5 years ago

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

guldmann0211 commented 8 months ago

Try changing ...

get-visiomaster -Name * -document $stencil_comp

guldmann0211 commented 8 months ago

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

guldmann0211 commented 8 months ago

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

saveenr commented 7 months ago

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