Lets take our look a Visio a bit further and move objects around and change the text labels
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 |
## create visio document
$visio = New-Object -ComObject Visio.Application $docs = $visio.Documents ## use basic template ## set active page ## Add a stencil ## Add objects $shape1 = $page.Drop($server, 2, 2) ## Resize Objects ## Connect Objects ## move objects ## Add text $doc.SaveAs("c:\scripts\visio\draw1.vsd") |
To move an object we can use the SetCenter method. The numbers are X & Y co-ordinates. The origin is at the bottom left corner (0,0). Depending on what units and paper size you are using – using A4 I get 8,11 as an approximation to the top right corner so I’m guessing the co-ordinates represent inches. Check on your implementation.
The text is simply changed by setting the Text property as shown.
Now we have the basics of working with Visio – its time to think what we can do with it.
By: Arnaud L. on June 6, 2011 at 5:35 am
Hi Richard, thank for all your posts about powershell v2 and Visio 2010, they help me very well !
I’ve just a question about an issue:
How can i add somes shape data information for original stencils ?
I mean, when i want to use Network Diagram stencil, they are some information (shape data) like “Location, Version, Type” etc … than can I (normally) set.
I can’t edit it with powershell. Have you some trick for this ?
thanks !
By: rad on January 20, 2012 at 4:01 am
How dó i rotate and object?