# Adding Underlay Hatching to MTEXT by Extracting and Offsetting Geometry

**URL:** <https://forum.dynamobim.com/t/adding-underlay-hatching-to-mtext-by-extracting-and-offsetting-geometry/73262>\
**Category:** Civil 3D\
**Tags:** geometry\
**Created:** [February 11, 2022, 6:42pm UTC](https://forum.dynamobim.com/t/adding-underlay-hatching-to-mtext-by-extracting-and-offsetting-geometry/73262 "2022-02-11T18:42:02Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![WrightEngineering](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/wrightengineering/32/115676_2.png) [@WrightEngineering](https://forum.dynamobim.com/u/WrightEngineering)\
**Post date:** [February 16, 2022, 1:30am UTC](https://forum.dynamobim.com/t/adding-underlay-hatching-to-mtext-by-extracting-and-offsetting-geometry/73262/10 "2022-02-16T01:30:02Z")

</div>

Luckily someone in the following forum post has shared the code within the “group\_curves” node in the following forum post: [Extracting closed Polycurves from given Surface - #2 by Mohammad\_Nawar](https://forum.dynamobim.com/t/extracting-closed-polycurves-from-given-surface/24086/2)

I was able to get it to work in my script, so I finally have joined polycurves that I am able to offset. However, I need a way to filter a polycurve that is contained within any polycurve that exists in a list. This is so letters like A and P only offset the exterior lines, not interior.

 ![Updated-2022-02-15](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/4/e4c94e733402829cd7a6a646e5c91605d004f0f3.png)  
[TextHalo.dyn](https://forum.dynamobim.com/uploads/short-url/2iTYwkauiy1BDOXoNCRqL8ICJtF.dyn) (16.3 KB)

```auto
#Copyright(c) 2015, Konrad Sobon
# @arch_laboratory, http://archi-lab.net

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

inputCurves = IN[0]

#join/group curves function
def groupCurves(Line_List): 
	ignore_distance = 0.1 # Assume points this close or closer to each other are touching 
	Grouped_Lines = [] 
	Queue = set() 
	while Line_List: 
		Shape = [] 
		Queue.add(Line_List.pop()) # Move a line from the Line_List to our queue 
		while Queue: 
			Current_Line = Queue.pop() 
			Shape.append(Current_Line) 
			for Potential_Match in Line_List: 
				Points = (Potential_Match.StartPoint, Potential_Match.EndPoint)
				for P1 in Points: 
					for P2 in (Current_Line.StartPoint, Current_Line.EndPoint): 
						distance = P1.DistanceTo(P2) 
						if distance <= ignore_distance: 
							Queue.add(Potential_Match) 
			Line_List = [item for item in Line_List if item not in Queue]
		Grouped_Lines.append(Shape) 
	return Grouped_Lines

OUT = groupCurves(inputCurves)

```

---

_[View the full topic](https://forum.dynamobim.com/t/adding-underlay-hatching-to-mtext-by-extracting-and-offsetting-geometry/73262)._
