Your code should cycle through all lines in the file. If a given line's end-points are inside the rectangle, then the line is inside the recetangle, so you should add this line to the delete list.
Here's some example code. It uses SNAP functions, but the basic idea would be same using NX/Open functions
Option Infer On Imports Snap, Snap.Create Public Class MyProgram Public Shared Sub Main() ' Use the rectangle from (3,4) to (7,9), as an example Dim lowerLeft = New Position(3,4) Dim upperRight = New Position(7,9) Dim deleteList As New List(Of NX.Line) For Each lin In Snap.Globals.WorkPart.Lines Dim startPtIn = PointInRectangle(lowerLeft, upperRight, lin.StartPoint) Dim endPtIn = PointInRectangle(lowerLeft, upperRight, lin.EndPoint) If startPtIn And endPtIn Then deleteList.Add(lin) Next Snap.NX.NXObject.Delete(deleteList.ToArray) End Sub Private Shared Function PointInRectangle(lowerLeft As Position, upperRight As Position, pt As Position) As Boolean Dim inside As Boolean = True If pt.X > upperRight.X Then inside = False If pt.Y > upperRight.Y Then inside = False If pt.X < lowerLeft.X Then inside = False If pt.Y < lowerLeft.Y Then inside = False Return inside End Function End Class