Creation Dynamo nodes with Revit API based C#

Hi, everybody
I’m newer in Dynamo and have some experience in calculating programming (C#). My task - investigations in sphere of Revit’s (and etc software) grounds and “zero-step” works. I wanted add new nods of Dynamo that will permit me use specific functions of Revit. (I am talking about Revit API)

F.e. lets consider situation - there is a node, that take a X,Y coordinates of selecting object/group of Revit’s object [f.e. any component - car, tree…], then analyze external text file [IFC/XML/TXT description of surface; User mark path to that file] and assign to Revit’s object Elevation’s property of it point of surface. As result - put object on surface with true Z-coordinate…

Most problem of me - how use Revit’s API for main purpose - create Dynamo’s node? I had read that article and that guide but there there are no both needing steps and I’m confused :frowning:

Сan you give me advices how will looked like code?
Below needing API’s functions

  1. For pick object - that
    2 For get XY coordinates of object - that and that
  2. For change point’s elevation - that

I’ll be great if smb can help me (I haven’t experience up that time to write even plugins with API)?
P.S. Even if that node is exists, I want understand logic of it creation.

The nodes you seek already exist. No need to reinvent the wheel - save the API doves for when they are needed.

Element.GetLocation will return the location point of the selected element in terms of XY and Z values.

A Point.Z node will pull the Z component from the resulting point.

The IFC’s Z point can be read a few different t ways but it appears you have an understanding of that already, so I’ll assume you have the second Z value.

Subtract the IFC Z value from the element point’s Z value to get a delta Z with a subtraction node.

Use the delta Z to define the Z component of a Vector.ByComponents node does you have the vector which the element needs to move by.

Use an Element.MoveByVector node to move the original elements to the correct elevation.

Hi, Jacob
Sorry for long-time waiting;
Yeah, I have that “way to find Z-value of point” and wanted shared it node here. There is a fact, that Revit “break” elevation’s geometry if it contain hard triangulation. So, optimal way - use surface’s geometry from base software. In my situation I used XML-definition of surface (from AutoCAD Civil 3D). Also there are ways to use other formats as IFC and etc.
Below I public my simple node that may be will useful for smb, that contain one Dynamo’s action - “ReadXML_file_ForGetElevationVersion2”. It was my first experience in writing node for Dynamo, at fact :sweat_smile:
How it works:?

  • in string “X_coord” (or Y_coord) you add coordinates of point
    Note: Revit’s units must be metre and if User have site in Revit (coordinates of Base Point != 0) before import coordinates of Point in that node User need sum it with Base Point coordinates because node “Element.GetLocation” return as I remember only coordinates from Base Point.
  • in string “data_input” you neeed insert absolute path to file without “” - as string further: C:\Work\Code_Experiments\AnalyzeSurface\00_Topoplan_Съемочная.xml
  • node created in VS 2017, on NetFRameworks 4.7 with Nuget DynamoVisualProgramming.ZeroTouchLibrary ver = and had been using on Revit 2020.3

Link to my node here (because I can’t public DLL file here)
P.S. I wanted know how use it with API because have other interesting Cases and there are not any free-packages (Dynamo) with needing functions.