Show gradients steeper than 1:21

Hi,

I came across a script from an old forum topic that changed the colours of floor/topography triangles when the slope exceeded a specified value. I’ve duplicated the script and updated a few parts to account for software changes since it was originally created.

However, I’ve now hit a roadblock. At a certain point in the graph, I receive the following error:

“Line.ByStartPointEndPoint operation failed. Unable to create Line. Points are likely coincident.”

I’m a bit stumped as to what’s causing it. My suspicion is that there may be some duplicate or overlapping points being generated somewhere in the process, but I haven’t been able to track it down.

The workspace is probably too large to export as a readable image, so I’ve attached the .dyn file instead.

I’d be very grateful if anyone could take a look and point me in the right direction. Any help would be much appreciated and might just stop my hair from going even greyer! :grinning_face_with_smiling_eyes:

Thanks in advance.

Floor_Slope_Compliance.dyn (487 Bytes)

Hey @Kev1311,

Heads up, the .dyn that came through is empty. It has no nodes, just a note that says “Populate with nodes…”. I think the wrong file got attached (maybe a save before the real one?). Can you upload it again?

While we wait, that error usually means a line is being built between two points that sit in the same spot. With floor/topo triangles, that’s typically one of these:

  • A triangle that is flat or degenerate (zero area), so the “slope” line has zero length
  • Duplicate vertices where neighbouring triangles share a point

To find the culprits, check the distance first and filter before building lines:

d = Point.DistanceTo(startPts, endPts);
keep = d > 0.001;

Then run keep through List.FilterByBoolMask on both point lists before Line.ByStartPointEndPoint. The out list will show which indices were the problem.

You could also skip the lines entirely and get the slope from each triangle’s normal:

n = Surface.NormalAtParameter(tri, 0.5, 0.5);
slope = Math.Sqrt(n.X * n.X + n.Y * n.Y) / Math.Abs(n.Z);
steep = slope > 1 / 21;

steep gives you the mask for colouring. It avoids the zero-length line problem and is a lot less work for the graph.

Post the real file and I’ll take a look.

If your script is very old, it probably won’t work with the new versions of TopoSolid (Revit 2024+).

as an alternative to @john_pierson answer

would getting the topo points, then run it through a prune duplicate points, then rebuilt the topo from those points work? You might need to add a tolerance i.e for points that are very close

I also have a vague memory that you might get errors like this if a plane is vertical

No points needed
Geometry > Topology.Faces > Surface > Normal > Angle with Z > Tan = Slope


Hi all,

Thank you so much for the replies! Gotta love these forums!

@Mike.Buttery That code looks exactly what I am looking to achieve! I will give that a go. Looks so much neater than my approach as well.

I have attempted to copy your method but I have a similar issue as before but with the List.FilterByBoolMask this time. Any ideas what could be causing the code to not work at this point?

I have changed the slope angle to a steep slope of 1:3 to check if that would make a difference. Unfortunately is never.

What does the warning say?