# Zero Touch Node - convert Autodesk.Revit.DB.Solid to Autodesk.DesignScript.Geometry.Solid

**URL:** <https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883>\
**Category:** Developers\
**Created:** [April 4, 2020, 2:37pm UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883 "2020-04-04T14:37:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yafim.simanovsky](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@yafim.simanovsky](https://forum.dynamobim.com/u/yafim.simanovsky)\
**Post date:** [April 4, 2020, 2:37pm UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/1 "2020-04-04T14:37:51Z")

</div>

Hi all,  
I’m having difficulties converting between a `Autodesk.Revit.DB.Solid` to a `Autodesk.DesignScript.Geometry.Solid` in a ZeroTouch node.

I’m extracting data from a curtain panel. First I extract the `get_Geometry()`, then I want to iterate over it and get the faces, edges etc…

The main problem is that _DesignScript_ doesn’t allow me access to `.Faces`, while _Revit.DB_ does.

The way to find the `FaceArray` in theory is (mainly looking at Revit Lookup) through the `GetInstanceGeometry`, `GetSymbolGeometry`, or `SymbolGeometry`, all of which return a `Solid`.

So far this is my relevant code:

```
GeometryElement panelGeometry = panel.get_Geometry(options); // get geometry
    foreach (Autodesk.Revit.DB.Solid geometry in panelGeometry) // iterate
    {
        FaceArray panelFaces = geometry.Faces; // get all faces

```

Nevertheless, there are 2 issues with this exploration that are bothering me:

1. Why does a rectangular panel element have 8 faces and not 6? (attached image)  

2. How to correctly convert the Solid in my code, so that I can access FaceArray, without getting the error displayed in Dynamo (attached error msg image)?  
 ![error](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/1/511605c8e9dc347335cb31b35063377a1336647f.jpeg)

I’ve tried looking online a lot, and tried various combinations of extracting the GetInstanceGeometry or trying to cast to different types, but without luck.  
Maybe I need to loop with a different Type and only then filter check for a Solid match? Not sure…

Any help would be appreciated.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Paolo\_Emilio\_Serra1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paolo_emilio_serra1/32/12902_2.png) [@Paolo\_Emilio\_Serra1](https://forum.dynamobim.com/u/Paolo_Emilio_Serra1)\
**Post date:** [April 4, 2020, 3:06pm UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/2 "2020-04-04T15:06:53Z")

</div>

For point 1, if you count the edges of the faces, 4 of them should be triangles (the larger faces). Can you confirm?  
For point 2, a GeometryInstance is still a collection of GeometryObjects, so you need to “drill down one more level” so to speak and treat the GeometryInstance as a GeometryElement.

---

<div class="post-metadata">

**Author:** ![yafim.simanovsky](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@yafim.simanovsky](https://forum.dynamobim.com/u/yafim.simanovsky)\
**Post date:** [April 5, 2020, 2:06pm UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/3 "2020-04-05T14:06:23Z")

</div>

@Paolo_Emilio_Serra1  
Thanks for the reply.  
I tried what you suggested and did make some headway, mainly from exploring better the `Solid Class`.  
[https://www.revitapidocs.com/2015/7a3b5ac1-c66d-9f81-a11d-9bcd4e026295.htm](https://www.revitapidocs.com/2015/7a3b5ac1-c66d-9f81-a11d-9bcd4e026295.htm)

So now I drill correctly down to the instances, but then I still can’t figure out how to translate `Autodesk.Revit.DB.Solid` to a `Autodesk.DesignScript.Geometry.Solid`, because the error I’m getting is:  
 ![error](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/8/78e2c3dda551350c2341cf199ab1b9720563f657.jpeg)

I can’t really cast one to the other… I was thinking there might exist some `.ToPrototype()` method like in Dynamo-Python, to convert and unwrap or wrap objects, but I don’t know if that’s relevant in Visual Studio and C#…

Any ideas…?

---

<div class="post-metadata">

**Author:** ![Paolo\_Emilio\_Serra1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paolo_emilio_serra1/32/12902_2.png) [@Paolo\_Emilio\_Serra1](https://forum.dynamobim.com/u/Paolo_Emilio_Serra1)\
**Post date:** [April 5, 2020, 2:19pm UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/4 "2020-04-05T14:19:45Z")

</div>

@yafim.simanovsky Have you tried looking into the Dynamo for Revit source code? [https://github.com/DynamoDS/DynamoRevit/blob/master/src/Libraries/RevitNodes/GeometryConversion/ProtoToRevitSolid.cs](https://github.com/DynamoDS/DynamoRevit/blob/master/src/Libraries/RevitNodes/GeometryConversion/ProtoToRevitSolid.cs)

> <https://github.com/DynamoDS/DynamoRevit/blob/master/src/Libraries/RevitNodes/GeometryConversion/RevitToProtoSolid.cs>

> <https://github.com/DynamoDS/DynamoRevit/blob/master/src/Libraries/RevitNodes/GeometryConversion/RevitToProtoFace.cs>

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [April 5, 2020, 4:11pm UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/5 "2020-04-05T16:11:23Z")

</div>

What exactly are you trying to do? In your OP question you state that you are trying to convert a Revit API Solid to a ProtoGeometry Solid, yet your thread only discusses face conversion?

Which is it?

For Faces you can only convert them to ProtoGeometry Surface using ToProtoType() (so yeah, it does apply in C#, the language is irrelevant; its simply a conversion method which recreates a geometry object from Dynamos geometry engine). Converting to a ProtoGeometry Face isn’t possible AFAIK, and I’ve never seen any example of a conversion from Revit API Face to ProtoGeometry Face.

For Solid you can still use ToProtoType().

Also, its impossible to cast a API Solid or Face to the equivalent type in the ProtoGeometry - you can only cast from an inherited class (or interface) to a subclass - its not a magic wand which can convert any type to any other type even from different libraries - a good analogy is trying to cast lead into gold; its never going to work. That’s why the conversion methods exist as they save the developer from having to rebuild/instantiate the respective geometry from scratch using the other geometry library (which behind the scenes is exactly what this method does which is not the same thing as casting which operates on the original object, it doesn’t instantiate a new one).

---

<div class="post-metadata">

**Author:** ![yafim.simanovsky](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@yafim.simanovsky](https://forum.dynamobim.com/u/yafim.simanovsky)\
**Post date:** [April 5, 2020, 4:58pm UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/6 "2020-04-05T16:58:37Z")

</div>

Hi,  
Thanks.  
@Thomas_Mahon I understand what you mean. In my original post I mistakenly referred to `Solid`, sorry.  
The more general question was how to get `Autodesk.Revit.DB` elements to be represented by `Autodesk.DesignScript.Geometry`, regardless of if it’s a `Solid`, `Face`, or `Edge`.

In all of these cases there isn’t a direct way to convert. I can “drill down” from `Solid` to `Edge` but at any point if I try to output anything to Dynamo, I get errors with this conversion problem.

I’ll take a look at the source code and methods you describe and come back if needed.  
Thanks guys 🙂

---

<div class="post-metadata">

**Author:** ![stillgotme](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@stillgotme](https://forum.dynamobim.com/u/stillgotme)\
**Post date:** [April 6, 2020, 1:14am UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/7 "2020-04-06T01:14:44Z")

</div>

The most efficient or accurate way i can think of is, if it is just a simple shape like a square or circle you can just to ToProtoType() method and cast it to its relevant geometry, else you would have to do a shape slicing (to simple geometries), and use ToProtoType() method, and then join them via solid union. If thats what you are asking

---

<div class="post-metadata">

**Author:** ![yafim.simanovsky](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@yafim.simanovsky](https://forum.dynamobim.com/u/yafim.simanovsky)\
**Post date:** [April 6, 2020, 6:55am UTC](https://forum.dynamobim.com/t/zero-touch-node-convert-autodesk-revit-db-solid-to-autodesk-designscript-geometry-solid/48883/8 "2020-04-06T06:55:07Z")

</div>

Hi all,  
After looking at the source code (thanks @Paolo_Emilio_Serra1) I was missing the **RevitNodes.dll** reference, therefore could not use the `Revit.GeometryConversion` namespace.  
Once finding that, I was able to use `.ToPrototype()` and achieve conversion like I wanted.

Thank you.
