Lunchbox 2016.11.10 - Lunchbox Room Element Collector Issue

The Lunchbox Room Element Collector is not working on the Revit 2017.1 dynamo 1.20 but works on Revit 2016? Has anyone encounter this?

Regards,
Emmmanuel

Hi @Emmanuel_Manago

Alternatively you can try @john_pierson “Rhythms” Package node “Room Element Collector” node.

1 Like

Thanks Kulkul! I hope the package get updated soon. It is really a great package. I will use the “Rhythms” package for now (also a great package).

1 Like

If you want to use the Lunchbox node, it just requires a change of one piece of code in line 82.

In the Revit 2017 API, the method changed from “BoundarySegment.Curve” to “BoundarySegment.GetCurve”.

I modified the script to figure out if the Revit version is 2016 or 2017 and use the correct method. Just past this in the python script.

#Copyright(c) 2015, Nathan Miller
# The Proving Ground, http://theprovingground.org

import clr

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

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

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

#The input to this node will be stored in the IN[0] variable.

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

appversion = app.VersionNumber
toggle = IN[0]

output = []
rooms = []
names = []
numbers = []
areas = []
levels = []
boundaries = []
locations = []
elementids = []
uniqueids = []

if toggle == True:

	collector = FilteredElementCollector(doc)
	collector.OfCategory(BuiltInCategory.OST_Rooms)
 
	famtypeitr = collector.GetElementIdIterator()
	famtypeitr.Reset()


	for item in famtypeitr:
		elmID = item
		eleminst = doc.GetElement(elmID)
    
		#print eleminst
		if eleminst.Area > 0:
			room = eleminst
			roomname = ''
			for p in room.Parameters:
				if p.Definition.Name == 'Name':		
					roomname = p.AsString()
				if p.Definition.Name == 'Level':				
					level = p.AsValueString()
					
			number = eleminst.Number
			area = eleminst.Area
			
			location = eleminst.Location.Point.ToPoint()
			elementid = eleminst.Id.ToString()
			uniqueid = eleminst.UniqueId
    	
			boptions = Autodesk.Revit.DB.SpatialElementBoundaryOptions()
			boundsegs = room.GetBoundarySegments(boptions)
			boundcurves = []
			if app.VersionNumber == 2016:
				for bound in boundsegs:
					crvs = []
					for seg in bound:
						crv = seg.Curve()
						crvs.append(Revit.GeometryConversion.RevitToProtoCurve.ToProtoType( crv, True ))
					boundcurves.append(crvs)
			else:
				for bound in boundsegs:
					crvs = []
					for seg in bound:
						crv = seg.GetCurve()
						crvs.append(Revit.GeometryConversion.RevitToProtoCurve.ToProtoType( crv, True ))
					boundcurves.append(crvs)			
    	
			rooms.append(room)
			names.append(roomname)
			numbers.append(number)
			areas.append(area)
			levels.append(level)
			boundaries.append(boundcurves)
			locations.append(location)
			elementids.append(elementid)
			uniqueids.append(uniqueid)
        
	output.append(rooms)
	output.append(names)
	output.append(numbers)
	output.append(areas)
	output.append(levels)
	output.append(locations)
	output.append(boundaries)	
	output.append(elementids)
	output.append(uniqueids)
        
#Assign your output to the OUT variable
OUT = output
3 Likes

Wow, thanks a lot John. It works now!
“The more I learn, the more I realize how much I don’t know.” - Albert Einstein

Regards,
Emmanuel

1 Like

Hi Guys

I have a question. I want to know whether can we add the parameters that we defined for the rooms in Revit into “LunchBox Room Element Collector” node in Dynamo. I defined a shared parameter namely " Assignable" which is a yes/no parameter and assigned this parameter to each room in my Revit model. Now I want to put it in my “LunchBox Room Element Collector” node. In fact this node as you know has some predefined parameters such as Element, Name, Number, Area, Level Name, Location, Boundaries, Element ID, and Unique ID. and I cannot add any more parameters to these outputs if I want. Do you know how I can do that? Than you so much in advance.

Quickest way = use a get parameter value by name node on the elements

Replacing the script did the trick for me! Many thanks! :sunglasses:

1 Like

When I downloaded the package, I cannot fond anyhthing