Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

Change process step from code


is there a way to change the process step programmatically?

Say I wanted to go to the next process step once a Boolean property becomes True. Is there anything like rootpart.ProcessSteps.GoToStep(ID)?

I only found information to read the current process step.


Thank you,


Accepted by topic author EI_Adrian
3 weeks ago

Re: Change process step from code



Here are a couple of snippets of code that should work for you.


This one will find the next process step:


Public Function ProcessStepNext() As String

        Dim nextProcessStep As ProcessStep = Nothing

        Dim currentIndex As Integer = -1


        For i As Integer = 1 To rootpart.ProcessSteps.Count

            Dim oProcessStep As ProcessStep = CType(rootpart.ProcessSteps.Item(i), ProcessStep)

            If oProcessStep.Name = rootpart.currentProcessStep.split("\")(1) Then

                currentIndex = i

                Exit For

            End If



        If currentIndex > -1 Then

            For i As Int32 = currentIndex + 1 To rootpart.ProcessSteps.Count

                Dim oProcessStep As ProcessStep = CType(rootpart.ProcessSteps.Item(i), ProcessStep)

                If oProcessStep.Status <> ProcessStepStatus.Disabled AndAlso _

                 oProcessStep.Status <> ProcessStepStatus.Hidden Then

                    nextProcessStep = CType(rootpart.ProcessSteps.Item(i), ProcessStep)

                    Exit For

                End If


        End If



    End Function


This one will let you pick the Process Step to navigate to:


SetProcessStep("YourProcessStepName", YourPartFamily)


  'Function that finds a specified process step and returns the object

    Private Sub SetProcessStep(ByVal sproc As String, ByRef epart As Part)


        'selected process step

        Dim sProcessStep As ProcessStep = Nothing


        'loop through all procesteps, find the process step passed by sproc


        For i As Integer = 1 To RootPart.ProcessSteps.Count

            Dim oProcessStep As ProcessStep = CType(RootPart.ProcessSteps.Item(i), ProcessStep)

            If oProcessStep.Name.Contains(sproc) Then

                sProcessStep = oProcessStep

                Exit For

            End If



        g_RsEngineer.SelectProcessStep(sProcessStep, epart, -1, 0)


    End Sub


Best Regards,


Re: Change process step from code

Thank you, Trent - that looks exactly like what I was looking for.