# Place View on same location

**URL:** <https://forum.dynamobim.com/t/place-view-on-same-location/59068>\
**Category:** Revit\
**Created:** [January 7, 2021, 6:19pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068 "2021-01-07T18:19:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 7, 2021, 6:19pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/1 "2021-01-07T18:19:20Z")

</div>

Hello Dynamo Community!

I have a View placed on a sheet:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/3/83fe35b8ef29d30f3d873d6e075f6bd14bfce23c.png)

I would like to **replace** the view with another one, which should be placed at the **same location**.

Placing a view on the sheet works fine with Viewport.Create from Rhythm:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/c/ac4eb753eabb26a06ab86037bea267002666e6e2.png)

And i also found a node to move a viewport to the same location as another one, works fine too, with Viewport.SetLocationBasedOnOther from Rhythm:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/5/8592c9ae2f3c19c4e6d7323bce12433d3af7f15b.png)

To put this all together i would need to get the viewport of the view. It doesn´t work with View.GetViewport from SteamNodes 🙁

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d3befbadceb496cbce9b7f30d40df3fb6176f3f8.png)

One solution would be to get all viewports on the sheet and then filter the one i need. I often have many views on a sheet and i really don`t know how i could filter the viewports.

For this easy example it would work like this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/e/7e96578966844d17d14e1ca7ecfd32bf909d24ad.png)

So why is the GetViewport node not working and is there any other method to get the viewport?  
Would be really happy for any advice!Thank you very much in advance 🙂

Regards, Gerhard

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [January 7, 2021, 6:34pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/2 "2021-01-07T18:34:13Z")

</div>

This should do it:

_(Note: make sure your crop regions are the same. I suggest using a scope box if the views are meant to be the same. Example = Multi level buildings)_

Example:

 ![20210107-replaceViewport](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/e/9e509cde9345497385fe9000f60f2b4aac0aa071.gif)

Graph:

 ![ReplaceViewport](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/7/97210d48593f7f048ff0578e6e63f6337848b164.png)

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 7, 2021, 7:08pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/3 "2021-01-07T19:08:23Z")

</div>

Hello John!

Thanks for your reply, thats exactly the intended use for my script.

In your and mine example we only have one viewport, but i have plans with many views and i don`t want to filter the viewports to get the one that should be the template viewport.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/5/95da65d2aa0ed7e9c702cf2c2a54b45c4bc43dff.png)

So i wanted to know if there is an easy way to get the viewport from a specific view.

I think that the viewport list and the view list won`t have the same order, so i can`t filter by a mask…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/3/43ca3565c8a026901ac8856845556bcbf2caa290.png)

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [January 7, 2021, 8:02pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/4 "2021-01-07T20:02:31Z")

</div>

Get a view’s viewport? (I might add this to Rhythm too)

Like this?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/0/802367da42a487cc9cd6b8ba411e0162f0e11a83.png)

Here is the Python:

```
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

def GetViewport(view):
	return filter(lambda v: v.ViewId.IntegerValue.Equals(view.Id.IntegerValue),FilteredElementCollector(doc).OfClass(Viewport))

#Preparing input from dynamo to revit
view = UnwrapElement(IN[0])

# return the results
if isinstance(IN[0], list): OUT = [GetViewport(x) for x in view]
else: OUT = GetViewport(view)
```

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 7, 2021, 8:24pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/5 "2021-01-07T20:24:57Z")

</div>

😍

wonderful! Thanks John! 😀

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/3/6369e29f609a1b3125414c43c7bb8d2127b4c38f.png)

Any idea why the SteamNode is not working? Code:

```
#python nodes in dynamo 1.0
#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

sheets = []
for i in IN[0]:
	sheets.append(UnwrapElement(i))

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

vplist=[]
for v in sheets:
	vp=[]
	a=v.GetAllViewports()
	for i in a:
		b=doc.GetElement(i)
		vp.append(b)
	vplist.append(vp)
			

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=vplist
```

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 8, 2021, 10:42am UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/6 "2021-01-08T10:42:32Z")

</div>

So after testing this in a larger script it does not work, the new view is placed somewhere else:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/d/cd645bb7b99946394272bdf842eb101d0720bace.png)

I place the view after setting the cropbox. So it should work because the views are equal!?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/2/024d9b96ad9e09f59a0bf2c215cf52aa2f37bbb5.png)

Edit:

Tried to add a END/START-Transaction to be shure the cropbox is applied.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/7/87401cd072fa23f2c2d5a3d87a12245fbe9a8617.png)

It works but now i have a litte offset, any ideas what could be the reason?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/1/5160ec309902f372db2fd3296e1ce6b871d93b2f.png)

---

<div class="post-metadata">

**Author:** ![Garbage\_Collector](https://avatars.discourse-cdn.com/v4/letter/g/da6949/32.png) [@Garbage\_Collector](https://forum.dynamobim.com/u/Garbage_Collector)\
**Post date:** [January 8, 2021, 11:13am UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/7 "2021-01-08T11:13:34Z")

</div>

Hi Gerhard,

I had the exact same issue a while back.  
a bit of a hacky solution since i bet there is a reason for this offset, but:

I removed the offset by doing this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/c/6c0d72206f90d60059b080c35445d4d82d1cc984.png)  
I am sure there is a better way to do this, but this resolved my issue so i havent looked into it further 🙂

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 8, 2021, 12:19pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/8 "2021-01-08T12:19:25Z")

</div>

I added this LocationBasedOnOther node at the end, but it does not work, still the same offset. I even tried it with End/Start-Transaction nodes.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/5/655594cf90dc4ec22c225b27d5018e3e6fd800be.png)

But if i run a standalone version it works perfect:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/c/ecc90a08ceca72c038a46f401788968c00325fa8.png)

I´ll keep trying to find a solution…interresting that it works for you MVE1112.

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 8, 2021, 12:47pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/9 "2021-01-08T12:47:26Z")

</div>

If i use an existing copy of the planview it works.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/8/9893b89e3c008ea2898531dc09aeba01726f4720.png)

So the problem has to be at creating an placing a Planview in one Dynamo session…

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 14, 2021, 10:54am UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/10 "2021-01-14T10:54:50Z")

</div>

I have found the reason for the offset, it`s because the viewports are not equal in size.

There are many elements that affect the viewport (grids, section lines, 2D-Elements,…), so these viewport location nodes are not reliable, at least not for my workflow.

It would be much more reliable if the location of the views would be set by the cropbox and not the viewport, because the cropboxes are always equal!

I will try to get the location of the cropbox on the sheet and move by vector or something like this.

For example, see how a section line affects the viewport:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/9/09bf4bf578e489138683bc0ecc880fea5b3ef11b.png)

---

<div class="post-metadata">

**Author:** ![jw.vanasselt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jw.vanasselt/32/133533_2.png) [@jw.vanasselt](https://forum.dynamobim.com/u/jw.vanasselt)\
**Post date:** [January 14, 2021, 12:57pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/11 "2021-01-14T12:57:39Z")

</div>

Hello,

There are many problems with locating viewports on sheets.

I don’t know exactly what you want to do but see the link below.  
Maybe another way, but it might help you!

> [@View gets incorrectly placed on sheet](https://forum.dynamobim.com/t/view-gets-incorrectly-placed-on-sheet/56544/15):
>
> We had the same issue over here. Try this: Use method 1 when you need to use a other point Y. Use method 2 when you only need the center. When you use more views you can use the node Curve.PointsAtEqualSegmentLength after the line. [Points.dyn](https://forum.dynamobim.com/uploads/short-url/by4DzDpnQrT36U4ux75tHbRwp4L.dyn) (61.9 KB)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [January 14, 2021, 2:05pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/12 "2021-01-14T14:05:34Z")

</div>

I have resolved this by turning off ALL annotation categories, get crop box, then turn back on, move the viewpoint as required. It’s a pain, but it works.

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [January 14, 2021, 8:36pm UTC](https://forum.dynamobim.com/t/place-view-on-same-location/59068/13 "2021-01-14T20:36:56Z")

</div>

Thanks for your replies!

What i want to do is to move one view to another one by using the cropboxes as reference instead of the viewports.

I would need this node but it does´nt work 😕

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/0/00c2290c5ef70a139a41525c07b5cfbde5ccc5c0.png)

I tried to make a vektor from one cropbox to the other one and then move by vector, but it does´nt work like this…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3f2bded6ee0ecbf481f65fc00e05e5e2cd2cbd9c.png)
