# Tool.CropViewfromRoomShape SteamNodes to a Group of Rooms

**URL:** <https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953>\
**Category:** Packages\
**Created:** [November 29, 2017, 5:51pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953 "2017-11-29T17:51:16Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Folgar\_Era](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alejandro_folgar_era/32/37120_2.png) [@Alejandro\_Folgar\_Era](https://forum.dynamobim.com/u/Alejandro_Folgar_Era)\
**Post date:** [November 29, 2017, 5:51pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/1 "2017-11-29T17:51:16Z")

</div>

Hello Everyone,

I´m trying to use the superuseful Tool.CropViewfromRoomShape from SteamNodes. But instead of using for single room I want to use for a group of rooms. ¿Any ideas? I don´t know how to deal with. I had tried to créate a boundary of the diferrents polycurves of each rooms but I couldn´t.

Thanks a lot!

 ![rooms](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/e/4e5b5ee82aef1a691d96b8b03b859b8551518096.PNG)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [November 29, 2017, 5:59pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/2 "2017-11-29T17:59:13Z")

</div>

Hi @Alejandro_Folgar_Era

Try changing @LISTLEVELS.

[http://dynamobim.org/introducing-listlevel-working-with-lists-made-easier/](http://dynamobim.org/introducing-listlevel-working-with-lists-made-easier/)

---

<div class="post-metadata">

**Author:** ![Alejandro\_Folgar\_Era](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alejandro_folgar_era/32/37120_2.png) [@Alejandro\_Folgar\_Era](https://forum.dynamobim.com/u/Alejandro_Folgar_Era)\
**Post date:** [November 29, 2017, 6:46pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/3 "2017-11-29T18:46:16Z")

</div>

thank you KulKul. I´ve read the link but I don´t understand how @listlevels can helpme. The Node just take the first room in the list. Do the work perfect, but just for one room. I need a selected rooms.

---

<div class="post-metadata">

**Author:** ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)\
**Post date:** [November 29, 2017, 9:16pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/4 "2017-11-29T21:16:26Z")

</div>

@Alejandro_Folgar_Era These are the internal contents of the Tool.CropViewFromRoomShape node:

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

The nodes I boxed in red are getting the room boundaries and offsetting them to be a closed curve that will define the Crop Region. What you will want to do, between the Polycurve.Offset output and the Python IN[0] input, is to get the outer most boundary curves of all of the room boundaries combined. Take the contents of the Tool.CropViewfromRoomShape node into your workspace, freeze the Python node and try out getting the outer most boundary curves from the Polycurve.Offset output… something like this could work but there might be a better way:

 ![boundary of group of rooms](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/8/d8492e5c879bb3b0a10dd3ed77047fba955be786.png)

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![Alejandro\_Folgar\_Era](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alejandro_folgar_era/32/37120_2.png) [@Alejandro\_Folgar\_Era](https://forum.dynamobim.com/u/Alejandro_Folgar_Era)\
**Post date:** [November 30, 2017, 12:36am UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/5 "2017-11-30T00:36:16Z")

</div>

Thank you awilliams, now I am close. It´s work fine to get the outline of complete groups of romos, but I don´t know why Python node doesn´t work with these inputs.

 ![Captura_dynamo1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/3/b3ad5a32ef5338aa3de212e453df2907fd12d9d5.PNG)

---

<div class="post-metadata">

**Author:** ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)\
**Post date:** [November 30, 2017, 12:40am UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/6 "2017-11-30T00:40:36Z")

</div>

From the Surface.Perimeter curves output, you need to find the sublist of curves that only pertain to the bottom surface of the combined solid. Put a watch node after the Surface.Perimeter curves node and look at the sublists of curves; there will be two groups of curves that are the longest (top and bottom surfaces of the solid). Of those two longest groups of curves, look for the list that the curves z values are all zero, then use GetItemAtIndex to pull that sublist of curves to use as the boundary for crop region

---

<div class="post-metadata">

**Author:** ![Alejandro\_Folgar\_Era](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alejandro_folgar_era/32/37120_2.png) [@Alejandro\_Folgar\_Era](https://forum.dynamobim.com/u/Alejandro_Folgar_Era)\
**Post date:** [November 30, 2017, 12:40am UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/7 "2017-11-30T00:40:48Z")

</div>

![Captura_dynamo2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/f/afffd08344629a94f6c055de073da8efa16665a4.PNG)

I also tried to take planar curves (doing intersection with a plane) , but get this error:  
““Advertencia: IronPythonEvaluator.Error en la operación EvaluateIronPythonScript.  
Traceback (most recent call last):  
File “”, line 41, in   
TypeError: iteration over non-sequence of type Curve””

---

<div class="post-metadata">

**Author:** ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)\
**Post date:** [November 30, 2017, 1:12am UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/8 "2017-11-30T01:12:08Z")

</div>

> [@Alejandro\_Folgar\_Era](#):
>
> TypeError: iteration over non-sequence of type Curve”"

Oops - my apologies @Alejandro_Folgar_Era; I hadn’t realized that the Python code was written to expect a list of sublists of curves. Here is a revised Python code that should work, but it will not accept a list of views and curves the way that the original Steam Nodes does, it will only allow you to run it on one view with one set of curves at a time:

```
import clr
#python nodes in dynamo 1.2
#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import Element wrapper extension methods
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

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

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

import System
import math
from System import Array
from System.Collections.Generic import *

looplist=[]
rm=[]
curves = IN[0]
view = UnwrapElement(IN[1])
RunMe=IN[2]

loop = (UnwrapElement(curves).ToRevitType())
ILoop=List[Curve](loop)
CL=CurveLoop.Create(ILoop)
looplist.append(CL)
if RunMe:
	# Start Transaction
	for i in looplist:
		TransactionManager.Instance.EnsureInTransaction(doc)
		#assign CurveLoop to the CropBox of the view
		view.CropBoxActive =True
		cropManager = view.GetCropRegionShapeManager()
		if cropManager.IsValidObject and cropManager.IsCropRegionShapeValid(i):					
			cropManager.SetCropShape(i)

	# End Transaction
	TransactionManager.Instance.TransactionTaskDone()
	doc.Regenerate()
else:
	OUT = 'Run Me set to False'

#Assign your output to the OUT variable.
OUT = view

```

IN[0] will be the polycurve from the joined room boundaries, IN[1] will be the view you want to crop, and IN[2] will be a boolean set to true to run the script, like so:

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

Hope this works for you, it works fully now on my end 🙂

Edit: the output on your PolyCurve.ByJoinedCurves from the Geometry.Intersect node might work too, just don’t use the Geometry.Explode node afterwards

---

<div class="post-metadata">

**Author:** ![Alejandro\_Folgar\_Era](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alejandro_folgar_era/32/37120_2.png) [@Alejandro\_Folgar\_Era](https://forum.dynamobim.com/u/Alejandro_Folgar_Era)\
**Post date:** [December 1, 2017, 12:11pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/9 "2017-12-01T12:11:14Z")

</div>

Thank you Again!, I get some kind or error on the Phyton I´d copied from your post.

Sorry about the mess around.

 ![phyton](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/c/3c93215a7d49a57f606307843a6eaa0d81d9b298.PNG)

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [December 1, 2017, 12:21pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/10 "2017-12-01T12:21:24Z")

</div>

The script is unnecessarily indented from `# Import RevitAPI`, you will see how it should be in the original node…

---

<div class="post-metadata">

**Author:** ![Alejandro\_Folgar\_Era](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alejandro_folgar_era/32/37120_2.png) [@Alejandro\_Folgar\_Era](https://forum.dynamobim.com/u/Alejandro_Folgar_Era)\
**Post date:** [December 1, 2017, 1:07pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/11 "2017-12-01T13:07:21Z")

</div>

I should erase the #import RevitAPI?? , I´d a look and are the same. May be I´m confusing. You refeer to this part os the code:

The original:

# Import RevitAPI

clr.AddReference(“RevitAPI”)  
import Autodesk  
from Autodesk.Revit.DB import \*

import System  
import math  
from System import Array  
from System.Collections.Generic import \*

------- the modified by awilliams —

```
# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

import System
import math
from System import Array
from System.Collections.Generic import *

```

* * *

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [December 1, 2017, 1:36pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/12 "2017-12-01T13:36:50Z")

</div>

Amy will probably correct it when she’s back but it looks like this indent is just a copy-pasting error:

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

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [December 1, 2017, 4:00pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/13 "2017-12-01T16:00:25Z")

</div>

Hi @Alejandro_Folgar_Era

Here is the DYN file [Crop View By PCurve(for Alejandro).dyn](https://forum.dynamobim.com/uploads/short-url/otqgNjwPyiditCwF4uJ3hbk6i6D.dyn) (6.8 KB). Hope it Helps!

---

<div class="post-metadata">

**Author:** ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)\
**Post date:** [December 1, 2017, 5:55pm UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/14 "2017-12-01T17:55:45Z")

</div>

Oops I’m sorry about that! @Yna_Db is right, I made a mistake when I copy and pasted the code for you. I just edited the post so the code is correctly indented 🙂

---

<div class="post-metadata">

**Author:** ![Alejandro\_Folgar\_Era](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alejandro_folgar_era/32/37120_2.png) [@Alejandro\_Folgar\_Era](https://forum.dynamobim.com/u/Alejandro_Folgar_Era)\
**Post date:** [December 13, 2017, 8:51am UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/15 "2017-12-13T08:51:58Z")

</div>

Thank you very much! , It´s was really helpful. Sorry I´m being really busy and didn´t anwer before.

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [December 13, 2017, 9:09am UTC](https://forum.dynamobim.com/t/tool-cropviewfromroomshape-steamnodes-to-a-group-of-rooms/16953/16 "2017-12-13T09:09:01Z")

</div>

@Alejandro_Folgar_Era Please mark the post as solved. You’re welcome!
