MikeShepard / VisioBot3000

Simple Visio Automation from Powershell
MIT License
50 stars 13 forks source link

New-VisioRackShape v1.1 PR #78

Open mc1903 opened 2 years ago

mc1903 commented 2 years ago

Hi @MikeShepard,

Pull Request for adding the New-VisioRackShape function as discussed in #77

I have included an example in the CBH and an extended example in the Examples folder.

Let me know if you want any changes/etc.

Cheers. M

MikeShepard commented 2 years ago

I’m out of pocket until Monday afternoon myself. Update mode happens when you open an existing document. I’d have to think about how to make it make sense in your example. I’ll see what I can do and touch base early in the week.

Get Outlook for iOShttps://aka.ms/o0ukef


From: mc1903 @.> Sent: Saturday, October 16, 2021 9:14:56 AM To: MikeShepard/VisioBot3000 @.> Cc: Mike Shepard @.>; Mention @.> Subject: Re: [MikeShepard/VisioBot3000] New-VisioRackShape v1.1 PR (#78)

@mc1903 commented on this pull request.


In VisioShape.ps1https://github.com/MikeShepard/VisioBot3000/pull/78#discussion_r730268837:

  • }
  • ElseIf ($RackVendor -match 'Cisco') {
  • $FirstUBXY = $FirstU
  • $FirstUEXY = $FirstU
  • $BeginXY = "=PAR(PNT($RackLabel!Connections.Cab$($FirstUBXY)A.X,$RackLabel!Connections.Cab$($FirstUBXY)A.Y))"
  • $EndXY = "=PAR(PNT($RackLabel!Connections.Cab$($FirstUBXY)B.X,$RackLabel!Connections.Cab$($FirstUBXY)B.Y))"
  • }
  • Else {
  • Write-Verbose "Rack Vendor $RackVendor is NOT known/supported. Skipping!"
  • Break
  • }
  • }
  • +<#

  • @Mike - unsure where $updatemode is set and if I need to worry about it here?

Hi Mike,

I hope you are well. Sorry it's taken me longer than I had planned to look at this again. It got busy at work and I spent most of last weekend replacing a built-in dishwasher; which turned out to be crash course in electrics, plumbing and carpentry!

I am still not getting how I invoke UpdateMode in order to test it. If you have 5 mins can you give me an example of how it should work/be invoked? I did look at New-VisioShape as you suggested but it doesn't help me tbh.

Do I need to add a -UpdateMode parameter to the New-VisioRackShape function? If this is the case, would a Set-VisioRackShape function be better for moving existing shapes?

Cheers M

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/MikeShepard/VisioBot3000/pull/78#discussion_r730268837, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABKI2IT7AGDNXZMHZ3V55Z3UHGCGBANCNFSM5EY6Q7BA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

MikeShepard commented 2 years ago

and...might be able to get to this tomorrow.

On Sat, Oct 16, 2021 at 5:09 PM Mike Shepard @.***> wrote:

I’m out of pocket until Monday afternoon myself. Update mode happens when you open an existing document. I’d have to think about how to make it make sense in your example. I’ll see what I can do and touch base early in the week.

Get Outlook for iOS https://aka.ms/o0ukef

From: mc1903 @.> Sent: Saturday, October 16, 2021 9:14:56 AM To: MikeShepard/VisioBot3000 @.> Cc: Mike Shepard @.>; Mention < @.> Subject: Re: [MikeShepard/VisioBot3000] New-VisioRackShape v1.1 PR (#78)

@.**** commented on this pull request.

In VisioShape.ps1 https://github.com/MikeShepard/VisioBot3000/pull/78#discussion_r730268837 :

  • }
  • ElseIf ($RackVendor -match 'Cisco') {
  • $FirstUBXY = $FirstU
  • $FirstUEXY = $FirstU
  • $BeginXY = "=PAR(PNT($RackLabel!Connections.Cab$($FirstUBXY)A.X,$RackLabel!Connections.Cab$($FirstUBXY)A.Y))"
  • $EndXY = "=PAR(PNT($RackLabel!Connections.Cab$($FirstUBXY)B.X,$RackLabel!Connections.Cab$($FirstUBXY)B.Y))"
  • }
  • Else {
  • Write-Verbose "Rack Vendor $RackVendor is NOT known/supported. Skipping!"
  • Break
  • }
  • }
  • +<#

  • @Mike - unsure where $updatemode is set and if I need to worry about it here?

Hi Mike,

I hope you are well. Sorry it's taken me longer than I had planned to look at this again. It got busy at work and I spent most of last weekend replacing a built-in dishwasher; which turned out to be crash course in electrics, plumbing and carpentry!

I am still not getting how I invoke UpdateMode in order to test it. If you have 5 mins can you give me an example of how it should work/be invoked? I did look at New-VisioShape as you suggested but it doesn't help me tbh.

Do I need to add a -UpdateMode parameter to the New-VisioRackShape function? If this is the case, would a Set-VisioRackShape function be better for moving existing shapes?

Cheers M

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MikeShepard/VisioBot3000/pull/78#discussion_r730268837, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKI2IT7AGDNXZMHZ3V55Z3UHGCGBANCNFSM5EY6Q7BA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- https://powershellstation.com

MikeShepard commented 2 years ago

Finally worked up an update example.

After running your rack example and saving the doc in c:\temp\rack.vsdx, move the rack to the middle of the page (manually) and save the diagram.

Copy your example script and change the new-visiodocument to open-VisioDocument -path c:\temp\rack1.vsdx -Update

This will open the document in "update mode"

Then, add to the end of the script this line (which just adds a new server to the rack) New-VisioRackShape -Master HPEDL360Gen108SFF -Label Server6 -RackLabel Rack01 -RackVendor HPE -FirstU 13

If it works, it would not move the rack back to the position specified in the script, but it would add the new server to the rack.

I've adjusted the VisioShape.ps1 file and attached it here. I think I got it working. VisioShape.zip

Just noticed that you're outputting $droppedShape if Verbose is specified...not sure why you'd to that.

mc1903 commented 2 years ago

Hi Mike,

Excellent, thank you. I will take a look over the weekend.

Ref "Just noticed that you're outputting $droppedShape if Verbose is specified...not sure why you'd to that."

As I was adding lots of rack equipment shapes, one after the other, the pages of $droppedShape output were just flashing past and giving me a bit of a headache. I felt I would only want to see the $droppedShape output if something wasn't working and I ran the function with -Verbose.

Cheers M

MikeShepard commented 2 years ago

About verbose...I see why you did that, but there are a couple of problems with that approach.

  1. Using Visiobot as a dsl requires that shape functions (like add-visioshape) output the shape object. It doesn't seem like the rackShape function will work in that mode so this isn't really a big deal.
  2. Verbose output should be done with Write-Verbose, and is text only. If you want optional object output, the accepted pattern is to add a -Passthru switch.

On Thu, Nov 4, 2021 at 4:58 AM mc1903 @.***> wrote:

Hi Mike,

Excellent, thank you. I will take a look over the weekend.

Ref "Just noticed that you're outputting $droppedShape if Verbose is specified...not sure why you'd to that."

As I was adding lots of rack equipment shapes, one after the other, the pages of $droppedShape output were just flashing past and giving me a bit of a headache. I felt I would only want to see the $droppedShape output if something wasn't working and I ran the function with -Verbose.

Cheers M

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MikeShepard/VisioBot3000/pull/78#issuecomment-960608284, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKI2IW332XNHUUMMQPZUXLUKJKOHANCNFSM5EY6Q7BA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- https://powershellstation.com

mc1903 commented 2 years ago

Morning Mike.

Updated as v1.4.

I encountered this issue with your suggested logic for $UpdateMode, so made a few changes that work for the following scenarios:

1) Normal Mode; Add New Shape 2) Update Mode; Move Existing Shape 3) Update Mode; Add New Shape

PS C:\Users\Martin> New-VisioRackShape -Master HPEDL180Gen108LFF -Label Server1 -RackLabel Rack01 -RackVendor HPE -FirstU 1
The variable '$DroppedShape' cannot be retrieved because it has not been set.
At C:\Program Files\WindowsPowerShell\Modules\VisioBot3000\1.1\VisioShape.ps1:274 char:18
+         If (-not $DroppedShape){
+                  ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (DroppedShape:String) [], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined 

Also, I took your earlier comments onboard, regarding my previous change to allow specifying the initial $X and $Y drop position, and have gone back to a fixed 0,0 position. But to mask the shape transition between the initial drop position and the final rack U position, I am disabling screen updating, dropping/moving and the enabling screen updating.

I am not too familiar with DSL, so have removed the logic that was suppressing the $DroppedShape output.

I hope this works for you, please let me know what you think.

Cheers M