# Manage Revit Elements from Custom Node (Convert Revit.Elements to Autodesk.Revit.DB)

**URL:** <https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056>\
**Category:** Developers\
**Tags:** revit, dynamo\
**Created:** [September 23, 2017, 2:43pm UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056 "2017-09-23T14:43:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LAU92](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@LAU92](https://forum.dynamobim.com/u/LAU92)\
**Post date:** [September 23, 2017, 2:43pm UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056/1 "2017-09-23T14:43:45Z")

</div>

Hi,

**My Background**  
I’m new to coding both for creating custom nodes for Dynamo and in generally. I have some experience with C# in Grashopper for Rhino, however I mostly created _calculation nodes_. I have considered Zero Touch by YouTube-videos from “Simply Complex” and “Danny Bentley”. Furthermore, I have become acquainted with the homepages “GitHub” and “thebuildingcoder”.

**Problem**  
I’m trying to create a custom node like [ClockWork: FamilyType.SetCompoundLayerWidth](https://github.com/andydandy74/ClockworkForDynamo/blob/master/nodes/0.9.x/python/FamilyType.SetCompoundLayerWidth.py), because I cannot get it to work (Dynamo 1.3 and Revit 2018). I would like to create it by C# (Zero Touch), as described in My Background I have some knowledge about this language and I to some degree can get help from a friend. As a reference I have looked at: [CmdNewWallLayer.cs](https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/CmdNewWallLayer.cs) from thebuildingcoder.

The problem I’m having is that in terms of my limited knowledge the only inputs from Dynamo to a custom node in this case is `Revit.Elements.`XXX. However, in order to alter the thickness of a layer by `CompoundStructure` it needs to by `Autodesk.Revit.DB.`XXX. By trying various things I quickly found out that you can’t set `Revit.Elements.WallType` equal to `Autodesk.Revit.DB.WallType` 🙂 (?) . I then tried to use the information from “[Intro to Zero Touch 202(creating a custom node that gets a Revit Element ID)](https://www.youtube.com/watch?v=lxJRom4z-Iw)” to maybe search by `ElementId` etc. Some examples of what I have tried is shown here ( sorry for the quality in advance 😉 ):

```
public static void GetWall(Revit.Elements.WallType element, double LW, int LI)
        {
            Autodesk.Revit.DB.WallType type;
            type = element;

            Autodesk.Revit.DB.CompoundStructure CS = type.GetCompoundStructure();
            CS.SetLayerWidth(LI, LW);
            type.SetCompoundStructure(CS);
        }

public static void Test4(Revit.Elements.Element element)
        {
            Autodesk.Revit.DB.Element UnW;
            UnW = element.InternalElement;
            if (UnW is Autodesk.Revit.DB.WallType)
            {
                Autodesk.Revit.DB.CompoundStructure CS = UnW.GetCompoundStructure();
                CS.SetLayerWidth(LI, LW);
                UnW.SetCompoundStructure(CS);
            }

```

**Questions**

- Can anyone maybe help my in the right direction to convert `Revit.Elements.WallType` to `Autodesk.Revit.DB.WallType`?
- Maybe in general how to convert wrapped Dynamo Elements to Revit Elements (vice versa)?
- 

_In terms of what I have understood by Pyhton Script this is solved by_ `UnwrapElement`

- So is more sensible I learn Python?

_Or_

- Is their some basic information that is necessary to know, that I did not find by my own search on the web?

Thank you for any help you can give.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 23, 2017, 5:28pm UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056/2 "2017-09-23T17:28:24Z")

</div>

> [@LAU92](#):
>
> So is more sensible I learn Python?

Kind of. I would learn Dynamo (most limited), then design script (easy language and adaptable for most cases), then Python (most flexible, most capable, broader support community for general stuff, and most used in the Dynamo workflows here). At least with a basic understanding of Python you can open up a node to make sense of how it handles these types of elements (for example the clockwork node you mentioned) and do some reverse engineering of it.

I know @Konrad_Sobon and others might recommend a different path. I specifically recall him saying learn C first in another thread (I went so far as to look for online tutorials and classes that night), but I can’t find that thread now.

You may want to post about the clockwork error as it should be resolvable.

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [September 23, 2017, 6:34pm UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056/3 "2017-09-23T18:34:22Z")

</div>

Just checked. None of the methods used in that node have changed in the 2018 API.

---

<div class="post-metadata">

**Author:** ![LAU92](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@LAU92](https://forum.dynamobim.com/u/LAU92)\
**Post date:** [September 23, 2017, 7:25pm UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056/4 "2017-09-23T19:25:32Z")

</div>

Thank you for the reply @jacob.small. I have tried to look into the clockwork-node and as @Andreas_Dieckmann says; the methods used is all available in the[2018 API](http://www.revitapidocs.com/). In terms of reverse engineering it, as you point out I need a better understanding of Python. In relation to the “error”, see my upcoming reply to the associated post by @Andreas_Dieckmann. Maybe I have misunderstood something.

However, I don’t know if the question of how to `UnwrapElement` by C# is still valid, since an answer will (maybe) make it much easier to utilize codes from thebuildingcoder and the Revit SDK?

---

<div class="post-metadata">

**Author:** ![LAU92](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@LAU92](https://forum.dynamobim.com/u/LAU92)\
**Post date:** [September 23, 2017, 7:34pm UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056/5 "2017-09-23T19:34:47Z")

</div>

Thank you for the reply @Andreas_Dieckmann.

I agree with you that the methods used in clockwork node is in the [2018 API](http://www.revitapidocs.com/). Maybe I have misunderstood something, please see the uploaded picture. The [FamilyType.SetCompoundLayerMaterial](https://github.com/andydandy74/ClockworkForDynamo/blob/master/nodes/1.x/Element.SetMaterialParameterByCategory.dyf) node is likewise from clockwork.

 ![Unavngivet1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/c/ec91cf636266a065b3ab0e3994061e279e2c141f.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 23, 2017, 9:53pm UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056/6 "2017-09-23T21:53:53Z")

</div>

The overlapping lines in the image are making it hard to follow the flow of data through your graph, which could be let of the problem. Can you change to curved connectors or adjust spacing so lines don’t overlap?

Also can you send a screenshot of the makeup of the wall (edit the structure in Revit so we can see the layout with the GUI). Some wall layers won’t let you change their thickness.

---

<div class="post-metadata">

**Author:** ![LAU92](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@LAU92](https://forum.dynamobim.com/u/LAU92)\
**Post date:** [September 24, 2017, 9:51am UTC](https://forum.dynamobim.com/t/manage-revit-elements-from-custom-node-convert-revit-elements-to-autodesk-revit-db/15056/7 "2017-09-24T09:51:56Z")

</div>

@jacob.small

![Unavngivet1](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/9/e/9e9029346f13500cf923c7f5f86e0dc696f7b105.png)  
 ![Unavngivet](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/d/9/d98cc94809f82c1373bcb011d3b7b87d654668ff.png)
