Select Parent Feature Given Line

After selecting a line I need to find the Feature that the line belongs to. What class/method can I use to extract this?

If you are interested in my motivation keep reading. I have a solid body (with lots of variation in thickness, not a single flat portion) that has lots of shapes projected onto it (hundreds). I need to break the surface apart into the constituent shapes that are projected onto the surface. Manually I do a law extension, selecting the surface and a single closed loop sketch that is projected onto the surface, then I do a split body, selecting the previous law extension and the solid body. I repeat these steps for each closed sketch on the surface.

I thought it might speed things up to have a tool that does the repetitive stuff and I can just select the next closed sketch when needed. I recorded a journal file that does the steps, but the specific curves, surfaces, features ... are populated, along with an excess amount of un-needed commands.

For the law extension, I need a line of the closed sketch along with the feature that contains the line. I have a journal for selecting the line, but now I need to get the associated feature.

Thanks for any help. I am also open to better ideas for this process. If this goes well, I would like to extend the program to create a new part and wave link in the newly formed body, save it and also export a step file. But first things first.

The code below may be a good starting point.




Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module2
 
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()
 
        Dim myCurve As Curve
        If SelectCurve("Select curve", myCurve) = Selection.Response.Cancel Then
            Return
        End If
 
        Dim featTag As Tag = Tag.Null
        Dim myFeature As Features.Feature
 
        theUfSession.Modl.AskObjectFeat(myCurve.Tag, featTag)
        If featTag = Tag.Null Then
            'curve is unused
            lw.WriteLine("curve is unused")
        Else
            myFeature = Utilities.NXObjectManager.Get(featTag)
            lw.WriteLine("used by: " & myFeature.GetFeatureName)
        End If
 
    End Sub
 
    Function SelectCurve(prompt As String, _
           ByRef selObj As NXObject) As Selection.Response
 
        Dim theUI As UI = UI.GetUI
        Dim cursor As Point3d
        Dim typeArray() As Selection.SelectionType = _
            {Selection.SelectionType.Curves}
 
        Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
                prompt, "Select a curve", _
                Selection.SelectionScope.AnyInAssembly, _
                False, typeArray, selObj, cursor)
 
        If resp = Selection.Response.ObjectSelected Or _
                resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
 
    End Function
 
End Module