Skip to content

Wrapped vs. Unwrapped Elements

Adam Bear edited this page Jul 31, 2018 · 9 revisions

Typically, the only reason you need to UnwrapElement is if you want access to the underlying Revit API calls themselves (And bare in mind you’ll have to wrap them up again if so for the Dynamo context to understand them).

Example:

In the example below, we do not UnwrapElement(). This gives us access to the Dynamo calls on the object (i.e the Wall is wrapped up into a Dynamo thing).

Wrapped Wall

If we UnwrapElement(wall) then this gives us access to the Revit API calls we can make upon the object (i.e the Wall is unwrapped).

Unwrapped Wall

The variance in the number count and calls themselves can be seen.

Addendum Example

Shout out to Adam Bear for the following image and code.

wrapped = dir(IN[0])
unwrapped = dir(UnwrapElement(IN[0]))

wrappedonly = []
unwrappedonly = []
unandwrapped = []
lens = []

for i in wrapped :
	if i not in unwrapped :
		wrappedonly.append(i)

for i in unwrapped :
	if i not in wrapped :
		unwrappedonly.append(i)

for i in unwrapped :
	if i in wrapped :
		unandwrapped.append(i)

wraps = wrapped, wrappedonly, unandwrapped, unwrappedonly, unwrapped
for i in wraps : lens.append(len(i))
nam = 'wrapped', 'wrapped only', 'unwrapped and wrapped', 'unwrapped only', 'unwrapped'
ven = [ [x, y] for x,y in zip(lens, nam) ]

OUT = ven, [ [x, y] for x,y in zip(ven, wraps) ]