How to pass through MText to a Polyline Property Set

I have a situation where we have structural piles placed in a file, polyline boundaries, and Mtext associated as a name to these boundaries. I need, ultimately, to get the piles associated to the mtext of polyline that the structural piles are contained in. So far, I have built a script that will take property set data of a polyline and apply that to the objects contained inside of the polyline, but here we receive the data in mtext, not the property set of the polyline. Any ideas how I can speed up this process to get the mtext placed into the polyline property set?

Hi @jbrunkhorst,

Some brainstorming…

First, determine which MText is associated with each polyline. If things are as consistent as your screenshot, then you can make an assumption that the closest MText to each polyline is the one you want. Get the polyline geometry, get the MText insertion points, compare all the distances using Geometry.DistanceTo with cross product lacing, sort the MText by distance, then get the first item in the list.

Second, figure out which piles (COGO points from what I can assume) are within each polyline. There are several ways to do this.

  • Patch the polycurves with a surface and then use Geometry.DoesIntersect to filter out the points that intersect the surface.
  • If the polycurves are generally rectangular and aligned with the world XY axes, then you could get the bounding boxes of the polylines with Object.Extents and the use BoundingBox.Contains to filter the points.
  • Convert the polycurves to polygons and then use Polygon.ContainmentTest to test the points
2 Likes

This is great feedback - thank you @zachri.jensen!!!

1 Like

@zachri.jensen
Okay now I am stumped… I am trying to find the cogo points that are within a polyline, so I tried both the Geometry.DoesIntersect node and the BoundingBox.Contains node and they are coming back as all false. I can confirm that creating the surface boundary in CAD, that the surface patch is in the right location and I can confirm that the COGO point location can be recreated through Dynamo in the same location, as well. Thoughts?

@jacob.small this also goes back to a forum post that you helped me out with a few days ago.


Guessing it’s an elevation issue. Try this: Create a code block containing List.UniqueItems(srf.PointAtParameter(0.5,0.5).Z == pnt.Z); and wire the first surface into the srf input and all the points into the pnt input. The result should be a single True if everything is planar. if there is an elevation difference on all points and the surface you’ll have a single false. If there is a mix you’ll have both.

You could also try looking at the model from the side, but where’s the fun in that?

that was it! Can’t believe I didn’t think about that. Thank you!

1 Like