Best way to deal with collected elements from Revit.DB

In this example, It looks like I don’t have the element.Faces method for elements that I collected from Revit api collector. This will work when I create another script to process the collected elements from collection scrip output. It looks like Dynamo will converted the Revit element into Dynamo element only for the script output, but within the same script. Is there a method to convert any type of Revit Element into Dynamo element so I can get advantage of the built-in Dynamo functions? Or should I keep using Revit API.DB library for rest of the scripts once I collected element from the FilteredElementCollector? Thank you!

So Dynamo has a built-in “wrapper” for objects. Everything that is a Revit element is wrapped before being used with Dynamo. Likewise, if you want to use anything you gathered using Dynamo with RevitAPI, you have to unwrap it first. Check out this page to read some in-depth info on wrapping and unwrapping objects and how to do so: https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration#wrapping

In this case, the item you are getting straight from a filtered element collector are Revit elements but the method you want to use is a Dynamo method, so you have to wrap the elements first. This is done with the .ToDSType(bool) command from the import “RevitNodes”. The link above explains how to use the bool argument and how to import the command.

2 Likes

Hi, kenny
Thanks for reply! What a helpful resource!