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

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, 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 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 :slight_smile: (?) . I then tried to use the information from “Intro to Zero Touch 202(creating a custom node that gets a Revit Element ID)” to maybe search by ElementId etc. Some examples of what I have tried is shown here ( sorry for the quality in advance :wink: ):

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.

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.

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

1 Like

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. 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?

Thank you for the reply @Andreas_Dieckmann.

I agree with you that the methods used in clockwork node is in the 2018 API. Maybe I have misunderstood something, please see the uploaded picture. The FamilyType.SetCompoundLayerMaterial node is likewise from clockwork.

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.

@jacob.small

Unavngivet1
Unavngivet