cancel
Showing results for 
Search instead for 
Did you mean: 

Change process step from code

Experimenter
Experimenter

Hi,

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,

Adrian

2 REPLIES

Re: Change process step from code

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Adrian,

 

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

        Next

 

        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

            Next

        End If

 

        Return nextProcessStep.name

    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

        Next

 

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

 

    End Sub

 

Best Regards,

Trent

Re: Change process step from code

Experimenter
Experimenter

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