Practical Dynamo – Moving Views on Sheets

For those of you that read through my previous post last week on creating sheets using Dynamo, you might have come to the end of the post only to realise that the views haven’t placed where you want them to be on the sheets.

For example, my sheet with the automatically placed view now looks like this

The first method I’m going to use nodes from both the Rhythm and Lunchbox packages which you can download from your package manager. Simply install the latest version.

 

The Rhythm package has some super useful tools for a whole range of different actions in Revit, but today we’re going to focus on the nodes that can help us manipulate the location of our views on the sheet.

To get started, we use the Sheet.GetViewportsAndViews node, we want to feed the sheets from our previous steps into this node and the node will give you the viewports, views and schedules as separate outputs. For this exercise, we’re only interested in the viewports. As always, while you’re reading through just click on the images to see them full size.

Next you need to use the Viewport.LocationData node from Rhythm. The outputs from this node are

bBox which returns the minimum (bottom left) and maximum points (top right) of the viewport bounding box.
boxCenter which returns the centre point of the viewport bounding box
boxOutline which returns the start and end points of each side of the viewport bounding box

For this example, we’re going to use the boxCenter option because we’re going to get tricky with it a bit later on. For those earlier that were wondering what the Use Levels option actually on the nodes, as you can see in my animation it changes the level of the list that we’re working with. Without the Use Levels option you would need to either use GetItemAtIndex or List.Deconstruct to get the data that you want to manipulate.

Next use the Points.DeconstructPoint node from the Lunchbox package, this will deconstruct your point into it’s individual X, Y & Z coordinates.

Now this is where we get too smart for our own good. I want my view to be placed in the middle of the available space on my titleblock. For my particular titleblock I know that the centre point is located at 378, 297 (yours may be different) and we already have the centre of the viewport from our Rhythm node.

To find how far we need to move the viewport, we need to subtract the view X centre value from the sheet X centre and the view Y centre value from the sheet Y centre. The code block is simply values I’ve chosen, you could think of them much like a parameter in a family.

The next step is to move the views. The vector gives the distance in X & Y coordinates that the view needs to be moved, the Vector.ByCoordinates and Element.MoveByVector nodes are both standard nodes within Dynamo.

And finally, the whole thing is tied together by pushing the viewport elements into the Element.MoveByVector node via a List.GetItemAtIndex, from which we’re taking the list elements at index 2.

Now sometimes when I run this script, I’ll see the following “Attempt to modify the model out side of transaction” error.

There is a simple solution to this. Just save your changes in Dynamo, close Dynamo and then re-open. Simply run the script again and everything will work!

 

An overview of our extension to the original graph from last week, I’ve highlighted the nodes from custom packages to make things a little easier as well, Captain BIMCAD actually called me out on last week’s example for not grouping my nodes!

12 thoughts on “Practical Dynamo – Moving Views on Sheets

  1. avatar Mohammed Faramawy says:

    thanks a lot that was very helpful for me

  2. avatar Patrick Podeyn says:

    Hi,
    If you include a transaction end and a transaction start it’ll cure having to close and reopen the dynamo graph.

  3. avatar Ryan Lenihan says:

    Thanks Patrick. I’ll update the post to reflect this.

  4. avatar Ylenia says:

    Thanks a lot for this post,
    but…what if the Lunchbox package is not working?

  5. avatar Ryan Lenihan says:

    Is it the entire lunchbox package that isn’t working, or just the single node?

    Lunchbox has an external installer now, so first try that. You can grab it from here https://provingground.io/tools/lunchbox/

  6. avatar Rami says:

    I was installed lunchbox package, but it not include point.DeconstructPoint node, please what is the propposed solution?

  7. avatar Ryan Lenihan says:

    Hi Rami, what version of Lunchbox do you have? I am seeing Points.DeconstructPoint (note that Points is plural)

    points.deconstructpoints

  8. avatar Rami says:

    thank for your reply, I installed 2018.8.8 version (installed from dynamo search package)..
    i download the last version (from this link:https://bitbucket.org/provingground-io/lunchbox-for-dynamo/src/master/) but i don’t know how i installed it …
    he is mentioned to “Open the Visual Studio solution file” but i don’t know which file (i don’t have Visual Studio)
    thanks in advanced

  9. avatar JB says:

    Any thoughts on how to move the center of the Cropped View (instead of the center of viewport) to the center of the sheet?

  10. avatar Ryan Lenihan says:

    I haven’t checked, but is it possible to create a bounding box on the crop region while in the sheet? As well if you have links or dwgs loaded that span outside the crop region you can unload these and the movement of the viewports will more accurately reflect based on the centre of the crop region, then reload them once you’re done.

  11. avatar JB says:

    I can grab the crop view bounding box, but I can’t find a way to get the geometry in paper space that would allow me to move to center of sheet. Bounding Box max/min/mid don’t seem to work with the crop region bounding box. I have an image of my graph, but not sure how to upload it here. The project I am working with is a large complex with many matchlines so the viewport is much larger than the sheet (I’m creating 20 sheets to show each level). So unloading links doesn’t help me in this case.

  12. avatar Ryan Lenihan says:

    as much as i hate suggesting it, try set up a temporary view template with everything turned off, or at least everything you think is causing the issue with locating the crop view. i have just last week been caught out by the matchlines in views and all my views were out of whack on first placement.

    as for posting images in comments, you could use an image host like imgur and then post the link in comments.

Leave a Reply to Ryan LenihanCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.