Cannot unwrap element?

I was able to unwrap element but somehow suddenly cannot, anything wrong with UnwrapElement?

Unwrap is used to go from the Dynamo for Revit reference to an element to the Revit native element.

As this point you’re providing is a dynamo point, it doesn’t have a need to unwrap.

7 Likes

I really don’t understand, I don’t understand this unpacking thing.

I think it’s because of the translations, but I don’t understand


Home.dyn (10.8 KB)

The elements we see in Dynamo aren’t the actual Revit elements, but a reference to the Revit elements. This allows Dynamo to use nodes to interact with the Revit data. This is referred to as wrapping. Instead of the Revit element they are now Dynamo objects, which contain all of the Revit element’s data within the wrapping.

However Python calls the Revit API directly, and so we have to remove the Dynamo wrapped elements to the native Revit elements. This is referred to as unwrapping. The unwrapping usually wants to happen in the same Python node where you want to work with the Revit content. As such we usually see the inputs unwrapped when pulling them from the Dynamo environment.

6 Likes

One more thing to add - there is more you can do with the Revit API that is exposed in Dynamo, but you can also see those things using the dir() function (Directory) in Python :slight_smile:

# Load the Python Standard and DesignScript Libraries
import sys
import clr


input = IN[0] # Getting a single Family Instance into the Python node

dynamoReference = dir(input) #Getting the 'directory' of things you can do to this Family Instance inside of Dynamo. Note this parallels what you can do under the 'Revit.Elements.FamilyInstance', 'Revit.Elements.Element' and a few more things that are not exposed in Nodes, such as "MemberwiseClone". 

revitReference = dir(UnwrapElement(input)) #Getting the 'directory' of things you can do to this Family Instance through the Revit API. This is way more expansive that what is exposed as nodes inside of Dynamo. 

dynamoCount = str(len(dynamoReference)) #Getting the amount of objects in the wrapped Dynamo Reference and making it a string
revitCount = str(len(revitReference)) #Getting the amount of objects in the unwrapped Revit Reference and making it a string

output = {'Dynamo Reference = ' + dynamoCount: dynamoReference, 'Revit Reference = ' + revitCount : revitReference} #Create a Dictionary of outputs

OUT = output #Push this Dictionary out of the Python node
9 Likes

Wonder! Excellent explanation. Understood now. Elements in dynamo are just representations of revit elements. Thank you very much! I will try again as instructed.

2 Likes

I really appreciate all the help and attention, but I’m a very beginner and it’s still very difficult for me to work with python on dynamo.

1 Like