# Get Crop views

**URL:** <https://forum.dynamobim.com/t/get-crop-views/24558>\
**Category:** Developers\
**Tags:** revit, python, dynamo, views\
**Created:** [August 7, 2018, 1:16pm UTC](https://forum.dynamobim.com/t/get-crop-views/24558 "2018-08-07T13:16:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mickael.g](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mickael.g](https://forum.dynamobim.com/u/mickael.g)\
**Post date:** [August 7, 2018, 1:16pm UTC](https://forum.dynamobim.com/t/get-crop-views/24558/1 "2018-08-07T13:16:56Z")

</div>

Hi everyone,

I’m trying to get a crop box on a view, to select it in dynamo. I already try to use the code from Konrad K Sobon, but well… here is the message I had :  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/b/1b66d676a48725b86b5c50cb84dab9686232a60a.png)

and here is the code :  
import clr  
clr.AddReference(‘ProtoGeometry’)  
from Autodesk.DesignScript.Geometry import \*

clr.AddReference (‘RevitAPI’)  
from Autodesk.Revit.DB import\*  
import Autodesk

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

view = IN[0]

doc = DocumentManager.Instance.CurrentDBDocument  
TransactionManager.Instance.ForceCloseTransaction()  
tGroup = TransactionGroup(doc, "Temp to find crop box element")  
tGroup.Start()  
trans1 = Transaction(doc, "Temp to find crop box element")  
trans1.Start()  
view.CropBoxVisible = False  
trans1.Commit()  
shownElems = FilteredElementCollector(doc, view.Id).ToElementIds()  
trans1.Start()  
view.CropBoxVisible = True  
trans1.Commit()  
cropBoxElement = FilteredElementCollector(doc, view.Id).Excluding(shownElems).FirstElement()  
tGroup.RollBack()

#Affectez la sortie à la variable OUT.  
OUT = 0

Do you have any ideas? what is wrong?

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [August 7, 2018, 2:15pm UTC](https://forum.dynamobim.com/t/get-crop-views/24558/2 "2018-08-07T14:15:20Z")

</div>

Hi @mickael.g,

Change “view = IN[0]” with view = UnwrapElement(IN[0])

```
#From Konrad Sobon
import clr
clr.AddReference(&quot;ProtoGeometry&quot;)
from Autodesk.DesignScript.Geometry import *

clr.AddReference (&quot;RevitAPI&quot;)
from Autodesk.Revit.DB import*
import Autodesk

clr.AddReference(&quot;RevitServices&quot;)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

view = UnwrapElement(IN[0])

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.ForceCloseTransaction()
tGroup = TransactionGroup(doc, &quot;Temp to find crop box element&quot;)
tGroup.Start()
trans1 = Transaction(doc, &quot;Temp to find crop box element&quot;)
trans1.Start()
view.CropBoxVisible = False
trans1.Commit()
shownElems = FilteredElementCollector(doc, view.Id).ToElementIds()
trans1.Start()
view.CropBoxVisible = True
trans1.Commit()
cropBoxElement = FilteredElementCollector(doc, view.Id).Excluding(shownElems).FirstElement()
tGroup.RollBack()

#Affectez la sortie à la variable OUT.
OUT = cropBoxElement

```

 ![Get%20crop%20view](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/9/a9bf52de415ceedb541267d5401bfb5653176535.png)

---

<div class="post-metadata">

**Author:** ![mickael.g](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mickael.g](https://forum.dynamobim.com/u/mickael.g)\
**Post date:** [August 8, 2018, 7:20am UTC](https://forum.dynamobim.com/t/get-crop-views/24558/3 "2018-08-08T07:20:06Z")

</div>

Hi,

thanks for your answer… I found a way to do this with existing node ^^ but I might need you help on another subject

> [@Rotating (free angle) cropviews with Python](https://forum.dynamobim.com/t/rotating-free-angle-cropviews-with-python/24587):
>
> Hi there ! I never used python before, but it seems that my problem has no other solution so… I begin with this program. End, of course, it doesn’t works. import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import \* clr.AddReference ('RevitAPI') from Autodesk.Revit.DB import\* import Autodesk clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager cropB…
