You have There are two threads on the same problem (two different op’s), maybe we can concentrate in just one…
Following is a sample that finds the text insertion point inside a closed planar curve and groups the text object with the curve. You can modify it to suit. Note that as it is set up now, if there is more than one text inside a curve, it will only grab the first one - this can also be changed. Note also that the text insertion point is projected to the curve plane for comparison, so it does not actually need to be in the same plane as the curve - just within the projection of it.
import rhinoscriptsyntax as rs
#planar closed curves
def cp_crv_filt(rhino_object, geometry, component_index):
return rs.IsCurvePlanar(geometry) and rs.IsCurveClosed(geometry)
#text objects
def to_filt(rhino_object, geometry, component_index):
return rs.IsText(geometry)
def GroupTextWContainingCrv():
msg="Select closed planar curves to process"
crvs=rs.GetObjects(msg,4,preselect=True,custom_filter=cp_crv_filt)
if not crvs: return
msg="Select texts to check"
txts=rs.GetObjects(msg,512,custom_filter=to_filt)
if not txts: return
txt_data=[(rs.TextObjectPoint(txt),txt) for txt in txts]
tol=rs.UnitAbsoluteTolerance()
for crv in crvs:
plane=rs.CurvePlane(crv)
for txt_item in txt_data:
#point is automatically projected to the curve plane for testing !!
if rs.PointInPlanarClosedCurve(txt_item[0],crv,plane,tol)==1:
#match found
group=rs.AddGroup()
rs.AddObjectsToGroup([crv,txt_item[1]],group)
#items grouped, remove text item from search to go faster
txt_data.remove(txt_item)
#go to next curve in list
break
GroupTextWContainingCrv()