Tool.CropViewfromRoomShape SteamNodes to a Group of Rooms

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!

Hi @Alejandro_Folgar_Era

Try changing @LISTLEVELS.

http://dynamobim.org/introducing-listlevel-working-with-lists-made-easier/

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.

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

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:

Hope this helps :slight_smile:

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.

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

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””

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:

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

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

1 Like

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

Sorry about the mess around.

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

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 *

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

image

Hi @Alejandro_Folgar_Era

Here is the DYN file Crop View By PCurve(for Alejandro).dyn (6.8 KB). Hope it Helps!

2 Likes

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 :slight_smile:

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

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