MikeShepard / VisioBot3000

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

Having trouble placing swim-lane containers on page and around all shapes #76

Open bfay65 opened 4 years ago

bfay65 commented 4 years ago

The code below places the logical container correctly: image but when I change that to a swimlane it seems to only center on the last shape and ignore all the others: image I'm assuming swimlanes and phases are different animals since they seem to respond differently to this code compared to the other containers. Is there a way to place the swimlanes first...then add the remaining containers? I can't figure out how to do that with the Bot, since:

  1. I don't see an example of laying out swimlanes and phases by themselves
  2. I don't see an example of laying content out into an existing container

Here's the code that works with the logical, but when I switch to SwimLane, it get's off-kilter: New-VisioApplication

New-VisioDocument C:\temp\TestVisio3.vsdx 
Register-VisioStencil -Name Containers -Path "C:\PS\VisioBot3000-master\Examples\MyContainers.vssx"
Register-VisioStencil -Name Servers -Path "C:\Program Files (x86)\Microsoft Office\root\Office16\Visio Content\1033\SERVER_U.vssx"
Register-VisioShape -Name WebServer -From Servers -MasterName 'Web Server'
Register-VisioContainer -Name Location -From Containers -MasterName 'Location'
Register-VisioContainer -Name Domain -From Containers -MasterName 'Domain'
Register-VisioContainer -Name Logical -From Containers -MasterName 'Logical'
Register-VisioContainer -Name Swimlane -From Containers -MasterName 'Swimlane'
Register-VisioShape -Name DBServer -From Servers -MasterName 'Database Server'

New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -contents {
#New-VisioContainer -shape (Get-VisioShape Swimlane) -label MyFarm -contents {
    New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_1 -contents {
       Set-NextShapePosition -x 1.5 -y 8
           New-VisioShape -master WebServer -label PrimaryServer    
           New-VisioShape -master WebServer -label PrimaryServer_2 
           New-VisioShape -master DBServer -label SQL01            
    }
    New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents {
        New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_2 -contents {
            New-VisioShape -master WebServer -label BackupServer   
            New-VisioShape -master WebServer -label BackupServer_2 
        }
    }
    New-VisioConnector -From MyDomain_1 -To MyDomain_2 -Label SQL -Color Red -Arrow
}   

Thanks Mike!

bfay65 commented 4 years ago

Note: When I move the "MyFarm" function shape, all 5 servers move with it, so it seems to still be a parent even though it may not encompass all servers visually. Ideally, I'd like to be able to lay down Functions and Phases first, then tell Visio where everything goes with phase/function designation as well as specific coordinates within.

MikeShepard commented 4 years ago

What happens if you comment out the Set-NextShapePosition command?

On Tue, Jan 7, 2020 at 1:13 PM bfay65 notifications@github.com wrote:

Note: When I move the "MyFarm" function shape, all 5 servers move with it, so it seems to still be a parent even though it may not encompass all servers visually. Ideally, I'd like to be able to lay down Functions and Phases first, then tell Visio where everything goes with phase/function designation as well as specific coordinates within.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MikeShepard/VisioBot3000/issues/76?email_source=notifications&email_token=ABKI2IQ5H4GWWCV5GOACIF3Q4TH63A5CNFSM4KD5QYL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJ6IQY#issuecomment-571728963, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKI2IW3XPRC63IFEO2HFHTQ4TH63ANCNFSM4KD5QYLQ .

-- https://powershellstation.com

bfay65 commented 4 years ago

Exact same thing, just the whole set of objects appear down further in the middle of the pager (with regard to Y coord.)

bfay65 commented 4 years ago

Figured part of it out...If I surround everything in the Swimlane into another object, then it works. I just would prefer not to have that extra layer: image

New-VisioContainer -shape (Get-VisioShape Swimlane) -label MyFarm -contents {
New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -contents {
    New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_1 -contents {
       #Set-NextShapePosition -x 1.5 -y 8
           New-VisioShape -master WebServer -label PrimaryServer    
           New-VisioShape -master WebServer -label PrimaryServer_2 
           New-VisioShape -master DBServer -label SQL01            
    }
    New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents {
        New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_2 -contents {
            New-VisioShape -master WebServer -label BackupServer   
            New-VisioShape -master WebServer -label BackupServer_2 
        }
    }
    New-VisioConnector -From MyDomain_1 -To MyDomain_2 -Label SQL -Color Red -Arrow
    }
}   
MikeShepard commented 4 years ago

After you've done that, can you call .ContainerProperties.Disband() on the "extra" container?

On Tue, Jan 7, 2020 at 2:22 PM bfay65 notifications@github.com wrote:

Figured part of it out...If I surround everything in the Swimlane into another object, then it works. I just would prefer not to have that extra layer: [image: image] https://user-images.githubusercontent.com/19259186/71926490-1311b780-3159-11ea-9bb0-68c3fa2178c6.png

New-VisioContainer -shape (Get-VisioShape Swimlane) -label MyFarm -contents { New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -contents { New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_1 -contents {

Set-NextShapePosition -x 1.5 -y 8

       New-VisioShape -master WebServer -label PrimaryServer
       New-VisioShape -master WebServer -label PrimaryServer_2
       New-VisioShape -master DBServer -label SQL01
}
New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents {
    New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_2 -contents {
        New-VisioShape -master WebServer -label BackupServer
        New-VisioShape -master WebServer -label BackupServer_2
    }
}
New-VisioConnector -From MyDomain_1 -To MyDomain_2 -Label SQL -Color Red -Arrow
}

}

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MikeShepard/VisioBot3000/issues/76?email_source=notifications&email_token=ABKI2ITIQWX5AGMYJDX2WA3Q4TP65A5CNFSM4KD5QYL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIKETTA#issuecomment-571754956, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKI2IUQOSNN74O5UZSQUYDQ4TP65ANCNFSM4KD5QYLQ .

-- https://powershellstation.com

bfay65 commented 4 years ago

Sure, so can I "set New-VisioContainer -shape (Get-VisioShape Logical)" equal to a variable when I first introduce it to get the object back again? I.E. $Log = New-VisioContainer -shape (Get-VisioShape Logical)

MikeShepard commented 4 years ago

If you give it a unique name, a variable will be created for it.

If you set it to a variable like that, you'll need to output the variable

$Log=... $Log

On Tue, Jan 7, 2020 at 2:34 PM bfay65 notifications@github.com wrote:

Sure, so can I "set New-VisioContainer -shape (Get-VisioShape Logical)" equal to a variable when I first introduce it to get the object back again? I.E. $Log = New-VisioContainer -shape (Get-VisioShape Logical)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MikeShepard/VisioBot3000/issues/76?email_source=notifications&email_token=ABKI2IXL6MIEROYGTAKDMELQ4TRNJA5CNFSM4KD5QYL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIKFXAQ#issuecomment-571759490, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKI2IQNNJITEQ5JF3KBNDDQ4TRNJANCNFSM4KD5QYLQ .

-- https://powershellstation.com

bfay65 commented 4 years ago

Hmmm...Same result with: New-VisioContainer -shape (Get-VisioShape Swimlane) -label MyFarm -contents { New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -contents { New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_1 -contents { Set-NextShapePosition -x 3 New-VisioShape -master WebServer -label PrimaryServer
New-VisioShape -master WebServer -label PrimaryServer_2 New-VisioShape -master DBServer -label SQL01
} New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents { New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_2 -contents { New-VisioShape -master WebServer -label BackupServer
New-VisioShape -master WebServer -label BackupServer_2 } } New-VisioConnector -From MyDomain_1 -To MyDomain_2 -Label SQL -Color Red -Arrow } $Logical.Disband() }

bfay65 commented 4 years ago

Did that wrong...When I do it "right", am losing the swimlane as well... image

New-VisioContainer -shape (Get-VisioShape Swimlane) -label Swim_1 -contents {
    New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -name Wrapper -contents {
        New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_1 -contents {
           Set-NextShapePosition -x 3 -y 8
               New-VisioShape -master WebServer -label PrimaryServer    
               New-VisioShape -master WebServer -label PrimaryServer_2 
               New-VisioShape -master DBServer -label SQL01            
        }
        New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents {
            New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_2 -contents {
                New-VisioShape -master WebServer -label BackupServer   
                New-VisioShape -master WebServer -label BackupServer_2 
            }
        }
        New-VisioConnector -From MyDomain_1 -To MyDomain_2 -Label SQL -Color Red -Arrow
    }
    $Wrapper.ContainerProperties.Disband()
}   
MikeShepard commented 4 years ago

Oh...well, it was worth a try. I don't have bandwidth to play around with this right now, but maybe this weekend.

On Tue, Jan 7, 2020 at 2:54 PM bfay65 notifications@github.com wrote:

Did that wrong...When I do it "right", am losing the swimlane as well... [image: image] https://user-images.githubusercontent.com/19259186/71928693-a1883800-315d-11ea-9669-86118ba136d8.png

New-VisioContainer -shape (Get-VisioShape Swimlane) -label Swim_1 -contents { New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -name Wrapper -contents { New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_1 -contents { Set-NextShapePosition -x 3 -y 8 New-VisioShape -master WebServer -label PrimaryServer New-VisioShape -master WebServer -label PrimaryServer_2 New-VisioShape -master DBServer -label SQL01 } New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents { New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_2 -contents { New-VisioShape -master WebServer -label BackupServer New-VisioShape -master WebServer -label BackupServer_2 } } New-VisioConnector -From MyDomain_1 -To MyDomain_2 -Label SQL -Color Red -Arrow } $Wrapper.ContainerProperties.Disband() }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MikeShepard/VisioBot3000/issues/76?email_source=notifications&email_token=ABKI2ITTA33ISLV5PO5Y77TQ4TTZHA5CNFSM4KD5QYL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIKHTCA#issuecomment-571767176, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKI2ITYCKPZU3WTL4OHGWDQ4TTZHANCNFSM4KD5QYLQ .

-- https://powershellstation.com

bfay65 commented 4 years ago

Ok, it worked to put it at the VERY end...Thanks!!!

FYI, I added a little tweak to get the multiple objects to stack in a slanted style so the labels won't clash (see images). Just added a += .2 Y value to the drop method in VisioShapes.ps1 image

Related issue (can start new issue if that makes more sense): Am trying to place and stack these swimlanes directly on top of each other (the way they naturally snap into place when you're manually building a diagram). Is there's a function in the bot (or in Com) that auto-measures the height of each lane to find a Y-value for the new lane to be below the first, or do I just need to add such function to your code (or add to the 'pseudo code' we use here)?

Here's what I have so far: image New-VisioApplication

New-VisioDocument C:\temp\TestVisio3.vsdx 
Register-VisioStencil -Name Containers -Path "C:\PS\VisioBot3000-master\Examples\MyContainers.vssx"
Register-VisioStencil -Name Servers -Path "C:\Program Files (x86)\Microsoft Office\root\Office16\Visio Content\1033\SERVER_U.vssx"
Register-VisioShape -Name WebServer -From Servers -MasterName 'Web Server'
Register-VisioContainer -Name Location -From Containers -MasterName 'Location'
Register-VisioContainer -Name Domain -From Containers -MasterName 'Domain'
Register-VisioContainer -Name Logical -From Containers -MasterName 'Logical'
Register-VisioContainer -Name Swimlane -From Containers -MasterName 'Swimlane'
Register-VisioShape -Name DBServer -From Servers -MasterName 'Database Server'

New-VisioContainer -shape (Get-VisioShape Swimlane) -label Swim_1 -name Swim_1 -contents {
    New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -name Wrapper -contents {
        New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_1 -contents {
           Set-NextShapePosition -x 3 -y 8
               New-VisioShape -master WebServer -label PrimaryServer    
               New-VisioShape -master WebServer -label PrimaryServer_2 
               New-VisioShape -master DBServer -label SQL01            
        }
        New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents {
            New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_2 -contents {
                New-VisioShape -master WebServer -label BackupServer   
                New-VisioShape -master WebServer -label BackupServer_2 
            }
        }
        New-VisioConnector -From MyDomain_1 -To MyDomain_2 -Label SQL -Color Red -Arrow
    }

}   
$Wrapper.ContainerProperties.Disband()
#$Next_Y = $Swim_1.Cells("PinY").Result("in") += ($Swim_1.Cells("Height").Result("in"))
 $Next_Y = 3.8

    New-VisioContainer -shape (Get-VisioShape Swimlane) -label MyFarm -name Swim_2 -contents {
New-VisioContainer -shape (Get-VisioShape Logical) -label MyFarm -name Wrapper -contents {
    New-VisioContainer -shape (get-visioshape Domain) -label MyDomain_3 -contents {
       Set-NextShapePosition -x 3  -y $Next_Y
           New-VisioShape -master WebServer -label PrimaryServer    
           New-VisioShape -master WebServer -label PrimaryServer_2 
           New-VisioShape -master DBServer -label SQL01            
    }
    New-VisioContainer -shape (Get-VisioShape Location) -label DRSite -contents {
        New-VisioContainer -shape (Get-VisioShape Domain) -label MyDomain_4 -contents {
            New-VisioShape -master WebServer -label BackupServer   
            New-VisioShape -master WebServer -label BackupServer_2 
        }
    }
    New-VisioConnector -From MyDomain_3 -To MyDomain_4 -Label SQL -Color Red -Arrow
    }
}   
$Wrapper.ContainerProperties.Disband()

Thanks again! Awesome stuff!

bfay65 commented 4 years ago

Ok, I fudged it to this for now...but this is assuming each lane has equal height. Not to mention, we really only want a title on the FIRST lane, but not others.

image

bfay65 commented 4 years ago

Hey Mike, Since I'm working with Cross-functional flowcharts, do you know of a way to add functions (Swim Lanes) to a drawing where they snap/stack directly on top of one-another (like in the UI) and the title box only shows on the TOP lane? Please see image/code above to see this issue.

Thanks!

MikeShepard commented 4 years ago

I haven't ever worked with swimlanes before.

On Tue, Jan 14, 2020 at 4:53 PM bfay65 notifications@github.com wrote:

Hey Mike, Since I'm working with Cross-functional flowcharts, do you know of a way to add functions (Swim Lanes) to a drawing where they snap/stack directly on top of one-another (like in the UI) and the title box only shows on the TOP lane? Please see image/code above to see this issue.

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MikeShepard/VisioBot3000/issues/76?email_source=notifications&email_token=ABKI2ISZEFUKDONKIKIGTR3Q5Y66PA5CNFSM4KD5QYL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI6NJ7Y#issuecomment-574412031, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKI2IRUGCZ6TQTWTY7U5DLQ5Y66PANCNFSM4KD5QYLQ .

-- https://powershellstation.com