Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bfay65 opened this issue Jan 7, 2020 · 14 comments
Open

Comments

@bfay65
Copy link

bfay65 commented Jan 7, 2020

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
Copy link
Author

bfay65 commented Jan 7, 2020

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
Copy link
Owner

MikeShepard commented Jan 7, 2020 via email

@bfay65
Copy link
Author

bfay65 commented Jan 7, 2020

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

@bfay65
Copy link
Author

bfay65 commented Jan 7, 2020

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
Copy link
Owner

MikeShepard commented Jan 7, 2020 via email

@bfay65
Copy link
Author

bfay65 commented Jan 7, 2020

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
Copy link
Owner

MikeShepard commented Jan 7, 2020 via email

@bfay65
Copy link
Author

bfay65 commented Jan 7, 2020

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
Copy link
Author

bfay65 commented Jan 7, 2020

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
Copy link
Owner

MikeShepard commented Jan 7, 2020 via email

@bfay65
Copy link
Author

bfay65 commented Jan 7, 2020

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
Copy link
Author

bfay65 commented Jan 7, 2020

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
Copy link
Author

bfay65 commented Jan 14, 2020

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
Copy link
Owner

MikeShepard commented Jan 15, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants