Issue with Unwrapping room element from LunchBox

Hi,
I’m using Lunchbox Room Element Collector in a Dynamo graph, which I then want to pass onto a ZeroTouch Node that accepts a RevitAPI Room Element.

I’m trying to Unwrap the rooms, which I understand is the way to go here to keep things consistant, but the following attached image doesn’t seem to success in converting from Dynamo to RevitAPI.

What am I doing wrong here…? Am I missing a reference perhaps?

Thanks

Unwrapping an element converts from Dynamo element TO Revit Elements which is what it looks like from the output. Can you elaborate on what you are trying to do or what isn’t working for you?

1 Like

Yes. Thanks for the reply.
I’m using the Lunchbox component to extract model Rooms. So far so good. The output of the component is the Revit.Elements.Room which I understand is in the DynamoAPI, not the RevitAPI.

I’m trying to convert the Revit.Elements.Room to Revit.DB.Room using the UnwrapElement method.
But the output of the Object.Type shows that the method didn’t succeed in converting the type.

Any ideas?
Thanks

What are you wanting to do with the Room, because the Revit.Elements.Room is the object that gives you full access to the Room and all of its parameters?

There are a few things going on here that I think are confusing, so let’s work through them.

The wrapper is just a way for the DynamoAPI to interact with Revit elements. Object.Type still returns the RevitAPI object type, even though the object is “wrapped”. You are correct in your understanding of unwrapping elements in python, however, python also automatically wraps them for you when it returns any RevitAPI object. Most nodes take the “wrapped” (Dynamo) object as the input because that’s just the “standard” format for Dynamo. I would be curious to see the ZT node you’re using that requires the unwrapped element. That may also give us some additional information on what you’re trying to accomplish that could lead to an alternative solution.

1 Like

I missed the ZTN reference initially. You actually need to get the Element.InternalElement in your ZTN. Check this reference for how to translate incoming elements in the ZTN environment.

https://alvpickmans.github.io/DynamoDevelopment-London-Hackathon-2019/03-ZeroTouch/04-RevitNodeDevelopment.html

1 Like

Hi Guys,
Thanks for the replies.

@SeanP If I try the method of e.InternalElement that is suggested in that article, I run into a problem that the Room elements I am dealing with are part of Autodesk.Revit.DB.Architecture and not Autodesk.Revit.DB, and the message I get is an error that it can’t convert from one to the other. I wonder if Rooms are somehow unique in their definition. If it was a Wall it would work as the article suggests…

@Nick_Boyts What I have is a ZT node written in Visual Studio. The inputs and manipulations I am performing on the elements are in the RevitAPI, such as getting room locations and extracting various Parameters for some boundary inclusion tests.
I want to keep things consistent and not mix Dynamo and Revit elements inside the same ZT node. I need specific parameters of Rooms that exist in the RevitAPI but not in the DynamoAPI.
So in order to find some Parameters of the Rooms I need to use a RevitAPI Room Element in my ZT node.
In Dynamo I’m extracting the Dynamo Room from the Lunchbox node, and I then want to pass it as input to my ZT node which has the following definition:

public static string GetData(Document document, List<Room> inputRooms, List<string> roomNames, List<Polygon> Polygons)
        { ... }

So I’ve tried converting the Dynamo Rooms in my graph to Revit Elements before inputting them to my ZT node using Python. If I can do this then I don’t have to make any conversions and using statements etc. in VS, and I can just use them directly as RevitAPI Room Elements.

Hope it’s clearer and maybe you have some insight.
Thanks!

The e.InternalElement will happen inside the ZTN, not in Python. I think your fighting a battle for no reason. The point of reference dll in VS is to do just exactly what you asking for.

This example just gets adjusted for rooms INSIDE your VS:

Internal void DoSomething(List<Revit.Elements.Room> rooms)
{
  //get Revit room element from the Dynamo-wrapped object
for(Revit.Elements.Room  rm in rooms)
{
Autodesk.Revit.DB.Architecture.Room revitRoom =  rm.InternalElement;
}
}
2 Likes

Thanks @SeanP, I was using e.InternalElement in the ZTN, not in Python :slight_smile:
It still gave me an error but I think it was something else in my code, so I rewrote the definition and now it’s all good.
Specifically the solution was:

using DynamoRoom = Revit.Elements.Room;

public static string GetData(Document document, List<DynamoRoom> inputRooms)
        {
            List<Room> revitRooms = new List<Room>();
            foreach (DynamoRoom dynRoom in inputRooms)
            {
                revitRooms.Add(dynRoom.InternalElement as Room);
            }
1 Like