'CamBam VBScript dh42 03/2015
    ' get a polyline that is a part of a polyline starting at u and ending at v (in current units)
    '
    '*****************************************************************
    '
    'CamBam.CAD.Polyline
    'CamBam.CAD.Entity
    '
    '*****************************************************************

    Sub main()

        Dim ent As Entity
        Dim pli As Polyline


        For Each ent In CamBamUI.MainUI.ActiveView.SelectedEntities

            If TypeOf ent Is Polyline Then

                pli = CType(ent, Polyline)

                SegmentInfo2(pli, 5, 20)

            End If

        Next ent

    End Sub

    Sub SegmentInfo2(p As Polyline, u As Double, v As Double)

        'u and v are the starts and end points given in distance (current units) from the start point of the polyline.
        'ex: u = 5, v = 20, return a polyline of a total lenght = 15 units (20-5) and 
        'the new polyline start 5 units after the start point of the source polyline
        '
        'if u and v are reverted, the resulting polyline is the same, but its direction is reversed.
        ' u and v must not be equal -> polyline of null lenght
        ' if the asked lenght is bigger than the lenght of the source polyline, all the polyline (after the sart point) is returned.


        Dim p2 As polyline = New polyline

        If u = v Then Exit Sub

        p2 = p.GetSegment(u, v)  'get a segment from u to v in current units

        CamBamUI.MainUI.ActiveView.CADFile.Add(p2)

    End Sub