I’m trying to create a Dynamo script to generate annotative spot elevation labels. I have two surfaces — EG and FG — and I want to subtract FG from EG to show the elevation difference. But I’m stuck; it doesn’t seem to work as expected. Has anyone run into this before or found a workaround? Any help would be greatly appreciated. Thanks in advance!
Hi and welcome to the forum! I would suggest that you read the warnings as they are usually quite helpful and will explain what is going wrong.
For example, the Surface.ElevationAtXY node wants a Surface object as the first input, and as Anton pointed out, the Choose TIN Surface Name will only give you a String output.
What you need for that is the Selection.SurfaceByName node.
Object.Geometry will also only give a Function call without any input and requires some additional nodes do give X and Y coordinates for the Surface.ElevationAtXY node.
Here is an example where I’ve selected a Circle in Civil 3D Modelspace with the Select Object node and then taken the center of that circle with Circle.CenterPoint, after which I can use Point.X and Point.Y to get coordinates as inputs for Surface.ElevationAtXY.
This in turn will give you the elevation difference in the center point of that circle.
I hope this was helpful and gets you started on getting what you need from the script
Hi, thank you so much for the warm welcome and for taking the time to explain things so clearly!
I really appreciate your detailed breakdown—especially the clarification about the Surface.ElevationAtXY input and the use of Selection.SurfaceByName instead of just the string from Choose TIN Surface Name. That definitely helps me understand where I went wrong.
The example you shared using a Circle and extracting the center point coordinates was also very helpful. I’ll try to follow your approach and build around that. Thanks again for pointing me in the right direction—this really helps me get started!
Thank you for the clarification! That makes sense now—I was mistakenly feeding a geometry object instead of a number for X and Y, and I see now that the Surface input requires the actual Surface object, not just its name. I’ll make those adjustments. Appreciate your help!
I tried switching surfaces just to check, and the same issue occurred. The script still says ‘running’ on the command line — it seems to be taking an unusually long time to complete.
You could try changing Selection.SurfaceByName with Civil Object by Name, because there is a warning that Selection.SurfaceByName might not be included in future versions of Civil 3D.
Also, I guess you will want to do something with the height differences calculated, so I have added an example of how you could add the height difference values to COGO points as descriptions.
Thanks for the tip! I’ll try using Civil Object by Name instead. I also appreciate the example of adding the height difference to the COGO point descriptions—it’s very helpful.
Would it be possible to format the output like this?
Point Number
FG:
EG:
DE:
I tried experimenting with the code block, but I couldn’t get it to work on my end. Apologies—I’m still new to coding and learning as I go.
As @zieios demonstrated, you just need to add line breaks to the strings between the “ “. "FG:" + FG + "m <line break> EG:" + EG + "m <line break> DE:" + DE + "m";
Also, I expanded the Code Block so you can see the steps it takes if you are using Civil 3D 2025 or earlier (like me) and how much easier it will be with the new Formatted String from Object node in Civil 3D 2026.2
Thanks for the detailed explanation! The line breaks between the strings make a lot more sense now. I also appreciate you expanding the Code Block so I can see the steps—this is very helpful. Excited to try it out!