Modifying modules and programs |
Using the Task object it is possible to load and save programs and individual modules. You can also unload programs, get the position of the motion pointer (MP) and the program pointer (PP) as well as modify a robot position.
Load modules and programsTo load a module or program file you need the path to the file in the file system of the controller. When the file is loaded into memory the RapidLoadMode enumeration argument, Add or Replace, specifies whether or not it should replace old modules or programs.
If the file extension is not a valid module (mod or sys) or program (pgf) extension an ArgumentException is thrown.
try { aTask.LoadProgramFromFile(aPrgFileName, RapidLoadMode.Replace); aTask.LoadModuleFromFile(aModFileName, RapidLoadMode.Add); } catch (ArgumentException ex) { return; }
Try ATask.LoadProgramFromFile(APrgFileName, RapidLoadMode.Replace) ATask.LoadModuleFromFile(AModFileName, RapidLoadMode.Add) Catch ex As ArgumentException Return End Try
You can save a program using the SaveProgramToFile method and unload it using the DeleteProgram method. These methods save and unload all modules in the task.
Task[] taskCol = aController.Rapid.GetTasks(); foreach (Task aTask in taskCol) { aTask.PrograamName = aTask.Name; aTask.SaveProgramToFile(saveDir); aTask.DeleteProgram(); }
Dim TaskCol As Task() = AController.Rapid.GetTasks() Dim AnObject As Object For Each AnObject in TaskCol ATask = DirectCast(AnObject, Task) ATask.ProgramName = ATask.Name ATask.SaveProgramToFile(SaveDir) ATask.DeleteProgram() Next
You can save a module by using the Module.SaveToFile method. As argument you use a path to the controller file system.
aModule.SaveToFile(aFilePath);
AModule.SaveToFile(AFilePath)
The Task.ProgramPointer property returns the current location of the program pointer (module, routine and row number), that is, where the program is currently executing. The same functionality is available for motion pointer by using the MotionPointer property.
ProgramPointer pp = aTask.ProgramPointer; if (pp != ProgramPointer.Empty) { int aStartRow = pp.Start.Row; ..... }
Dim APP As ProgramPointer = ATask.ProgramPointer If Not APP = ProgramPointer.Empty Then Dim AStartRow As Integer = APP.Start.Row .....
Using the ModifyPosition method of the Task object you can modify the position of a RobTarget instance in the currently loaded program. As arguments you supply a module Name as well as a TextRange object. The first RobTarget within the text range specified by the TextRange object will be changed using the current TCP of the active mechanical unit.
this.ATask.ModifyPosition(aModule, aTextRange)
Me.ATask.ModifyPosition(AModule, ATextRange)
![]() |
---|
For more information on Task methods and properties, see in the Reference Manual FlexPendant SDK. |