Create Assembly sequence to get motion Envelope_NX 9

I have the following requirement. create a sweep envelop of the assembly items based on movement. (Example a rack and pinon is there I want to have maximum and minimum limits as a body or facet). In NX9 I believe there is no direct NX open methods for sequencing, I have to go with UF only.

1. Create sequence.

2. Start sequence motion based on CSYS to CSYS component move or each arrangement as a motion from default position.

3. Measure the sweep volume for all the motions to find the complete volume of all mechanism.

Here create step throwing Fatal Error (I don't understand the concepts of MyT and MyC). Also I want to know after creating step how to move components and create motion envelope.

Option Strict Off
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Features
Imports NXOpen.Utilities

Module Sequence

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim theUI As UI = UI.GetUI
Dim ufs As UFSession = UFSession.GetUFSession
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

lw.Open()

ufs.Assem.InitializeSequencing()
Dim SeqName As String = "Motion Envelope Sequence"
Dim Mysequence As NXOpen.Tag = Nothing
ufs.Assem.CreateSequence(SeqName, workPart.Tag, Mysequence)
'ufs.Assem.AskSequenceName(Mysequence, SeqName)
'MsgBox(SeqName)
' ufs.Assem.ActivateSequence(Mysequence)
Try
Dim MyT As Double = 10
Dim MyC As Double = 5
Dim Desc As String = "Motion_1"
Dim MyStep As NXOpen.Tag = Nothing
ufs.Assem.CreateStep(Mysequence, workPart.Tag, 1, MyT, MyC, Desc, Tag.Null, MyStep)
Catch ex As Exception
lw.WriteLine(ex.Message)
End Try

End Sub
End Module

I'm not very familiar with the sequencing commands, but according to the API help docs, the second input to the .CreateStep method is a tag of the part occurrence being sequenced. A "part occurrence" would be a component. Instead of passing in a part tag, try passing in a component tag.

The MyT and MyC variables represent the time and cost of the sequence step. If you are not interested in keeping track of time or cost, you can enter 0's for the values.