Dynamo - Civil 3D Feature Lines Editing

Hello all, I’m fairly new to Dynamo and I’m seeking help on how to create a Dynamo script. What I’m trying to achieve is for Dynamo to get all the Feature lines inside a Civil 3D file and find the slope of the feature line. Keep in mind the feature line will only have 2 points. If the slope of the feature line exceeds a certain percentage, let’s say 5%, then adjust the elevation as such so that the slope meets the requirement of 5% or less. Can someone help me or guide me on who to create this script? I do not have any python skills but willing to learn.

Hi @mike.perez,

Definitely doable. Which version of Civil 3D are you using? That will make a big difference.

currently using civil 3D 2025

Great, that will make it easier :slight_smile:

Here’s how you can do that:

Add on the FeatureLine.GradeAtStation node. Station 0 will be at the start of the feature line. Since all of your feature lines only have a single segment (i.e., two points max), then it doesn’t really matter what station value you use as long as it is in the range of 0 <= station <= feature line length.

Another way to say this is that you want to filter out the feature lines with grade > 5%. You’ll have to decide if this is “grade ahead” or “grade back”, depending on how your feature lines are set up. The way to filter them is to use the List.FilterByBoolMask node.

Now you have two buckets: the feature lines with grade > 5% (the in list), and all the others (the out list). Adjusting the grade is a little more work, but nothing crazy. What you need to do is calculate what the elevation of the end point should be, then set the point elevation to that value.

Full graph here for reference:
AdjustFeatureLineGrade.dyn (33.1 KB)

2 Likes

This worked great Zachri. Exactly what I wanted to do. How would I add a selection function at the beginning to select multiple feature lines?

There is a node called Select Objects that you can use.

What would I need to replace the input with to make the 5% slope max a variable. So, if I wanted to make the max be 10% slope or say 8% slope.

Right here. You can type it whatever you like.

Is there a simple way to use Excel to import data to edit feature lines? I’m able to build a script to bring the data from excel but how do I apply it to the feature lines that currently exist in the drawing? I guess a better question should be, Can I add an IF statement to this script that you created for me to say that if grade out is more than 10%, bring it down to 10% if not then leave it alone.

I did this in excel by exporting the data and then manipulating it there.

Generally yes, you can import whatever data you need from Excel. A couple of nodes you can try:

That should already be covered by this above: