Project Files

Visual Studio 2012 projects. Right-click to save

Print STEP-NC Workingsteps

The sample program below prints the operations in a STEP-NC file. It prints each workingstep and notes where workplan groups begin and end. The program uses the the Finder to read the data and the Adaptive to iterate over the process.

There are sample projects in C# and Visual Basic. The cursor walks the process until it reaches the next requested event. the start of the program, we request events for the start of an operation and the start and end of each workplan.

At each iteration, we examine the type of event and then print some identifying information from the process stack. The Visual Basic version of the sample program is shown below.

Imports STEPNCLib

Sub Main()
    Dim finder As finder = New finder
    Dim ctl As Adaptive = New Adaptive

    '' Read a STEP-NC file
    finder.Open238(sample_file.stpnc)

    '' Start traversing the process within the file.
    '' Uses the active data from finder.
    ctl.StartProject()

    '' Select only workplan start/stop, and individual workingsteps
    ctl.SetWantedAll(False)
    ctl.SetWanted(Adaptive.CtlEvent.EXEC_WORKPLAN_START)
    ctl.SetWanted(Adaptive.CtlEvent.EXEC_WORKPLAN_END)
    ctl.SetWanted(Adaptive.CtlEvent.OPERATION_START)

    While ctl.Next() <> Adaptive.CtlEvent.DONE
	Dim id As Long

	Select Case ctl.Event()
	    Case Adaptive.CtlEvent.EXEC_WORKPLAN_START
		id = ctl.GetActiveWorkplan()
		Console.WriteLine(STARTING WORKPLAN #{0} [{1}], id, finder.GetExecutableName(id))

	    Case Adaptive.CtlEvent.EXEC_WORKPLAN_END
		Console.WriteLine(ENDING WORKPLAN #{0}, ctl.GetActiveWorkplan())

	    Case Adaptive.CtlEvent.OPERATION_START
		id = ctl.GetActiveExec()
		Console.WriteLine(STARTING OPERATION #{0} (workstep #{1}) [{2}],
		    ctl.GetActiveOperation(), id, finder.GetExecutableName(id))

	    Case Else
		Console.WriteLine(UNEXPECTED EVENT)
	End Select
    End While
End Sub