Traceback errors

Hi all,

I am trying to run a simple script to assign space data fields to MEP elements using “Elements in Space” but am stuck at a roadblock of a “Traceback error”.
Is there something obvious im missing?

Thanks in advance.

John

You need to connect space elements list. Currently your feeding string values.

1 Like

Im not sure this is correct. it returns a similar Traceback error. I also need to get the space name into the script too somehow.

Apologies, i loaded the wrong image.

Try changing the lacing to longest and elements in space node.

I checked the node and it is working as expected.

And here is another way to achieve…

I appreciate the help, i tried the first option and i still have the traceback errors. I have copied you exactly. Perhaps i need to update something?

I will try the second option now.

Could you share with us your rvt file here.

I cant. The file it too big. Ive trimmed all of the fat from it but its still too large. Its essentially a .maj file imported from Cadduct.

Could you drop it in one of the dropbox services and share the link here.

Hopefully this works. Thanks again.

I cant explain my errors at all. I have reloaded the relevant packages and updated to the latest Dynamo version but still have no success.

a fresh look at it tomorrow might bear some fruit… thanks again.

The reason why “Elements in Space” doesn’t work because these (Fabrication Ductworks) are Unknown Elements. But you could use the below solution to get this done.

import clr
clr.AddReference('RevitAPI')
clr.AddReference('System')
clr.AddReference('RevitNodes')
clr.AddReference('RevitServices')
import Revit
import RevitServices
from Autodesk.Revit.DB import *
from System.Collections.Generic import List
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument

#Functions for list handling
def ProcessList(_func, _list):
   return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )

#Preparing input from dynamo to revit

def ToRevit(item):
	return item.ToRevitType(True)

if isinstance(IN[0], list):
	bblist = ProcessList(ToRevit, IN[0])
else:
	bblist = [ToRevit(IN[0])]

def collectElementsInBB(bb):
	outline = Outline(bb.Min, bb.Max)
	filter = BoundingBoxIsInsideFilter(outline)
	collector = FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_FabricationDuctwork).WherePasses(filter)
	return [e.ToDSType(True) for e in collector]

OUT = ProcessList(collectElementsInBB, bblist)
2 Likes

I will check it out, although im not sure bounding box works great as some spaces i have are ‘L’ shaped. I believe bounding boxes take the opposite corners of the space to create the box, in which case elements outside of the space may be captured by the bounding box, giving false results.

In which case, the duct on the right would be captured in the bounding box created on the left.

has anyone come across this bounding box problem before? It seems like an issue that must have been tackled previously?

I have used a polygon containment test in the past to get around this. It removes the z heights from the equation though so that may or may not be of benefit.

Get the spaces’ curves and build a polygon from them. Get the elements’ locations. Project both onto the level’s plane (may be unnecessary but I can’t test). Use a polygon containment the locations and the curves. Filter out elements accordingly and set space names to element parameters as desired.

If you need to evaluate on the Z axis the bounding box method above can be used as a first test. List management will be fun on that route.