RsMoveInstruction Properties Example
This example requires the prior execution of RsMoveInstruction Movement Methods Example. The example creates a new move instruction, and sets some properties. It then prints some information regarding the move instruction in the logger (the output window in RobotStudio).
Compiling the Code
Note
You need to add System.Drawing as a reference for this example to work!
Example
Project.UndoContext.BeginUndoStep("RsMoveInstructionProperties");
try
{
Station station = Station.ActiveStation;
// Create a move instruction in the constructor examples.
RsMoveInstruction myMove = (RsMoveInstruction)station.ActiveTask.FindPathProcedureFromModuleScope("myPath", "").Instructions[0];
// Set the color of the move instruction to yellow.
myMove.Color = Color.Yellow;
// Make the thickness of the move instruction twice as thick.
myMove.Thickness = myMove.Thickness * 2;
// Output some info regarding the move instruction.
Logger.AddMessage(new LogMessage("The Move Instruction has ProcessDefinitionName '" + myMove.ProcessDefinitionName + "'"));
Logger.AddMessage(new LogMessage("The Move Instruction has ProcessTemplateName '" + myMove.ProcessTemplateName + "'"));
Logger.AddMessage(new LogMessage("The Move Instruction '" + myMove.Name + "' has '" + myMove.InstructionArguments.Count + "' Instruction Arguments"));
RsInstructionArgument myCirPointArg = myMove.GetCirPointArgument();
if (myCirPointArg != null)
{
Logger.AddMessage(new LogMessage("CirPointArg Name: '" + myCirPointArg.Name + "' Value: '" + myCirPointArg.Value + "'"));
}
RsProcessTemplate myProcTempl = myMove.GetProcessTemplate();
if (myProcTempl != null)
{
Logger.AddMessage(new LogMessage("ProcessTemplate Name: '" + myProcTempl.Name + "' ActiveMotionType: '" + myProcTempl.ActiveMotionType + "'"));
}
RsInstructionArgument myToJointPosArg = myMove.GetToJointPosArgument();
if (myToJointPosArg != null)
{
Logger.AddMessage(new LogMessage("ToJointPosArg Name: '" + myToJointPosArg.Name + "' Value: '" + myToJointPosArg.Value + "'"));
}
RsInstructionArgument myToolArg = myMove.GetToolArgument();
if (myToolArg != null)
{
Logger.AddMessage(new LogMessage("ToolArg Name: '" + myToolArg.Name + "' Value: '" + myToolArg.Value + "'"));
}
RsInstructionArgument myToPointArg = myMove.GetToPointArgument();
if (myToPointArg != null)
{
Logger.AddMessage(new LogMessage("ToPointArgument Name: '" + myToPointArg.Name + "' Value: '" + myToPointArg.Value + "'"));
}
RsInstructionArgument myViaPointArg = myMove.GetViaPointArgument();
if (myViaPointArg != null)
{
Logger.AddMessage(new LogMessage("ViaPointArg Name: '" + myViaPointArg.Name + "' Value: '" + myViaPointArg.Value + "'"));
}
RsInstructionArgument myWObjArgument = myMove.GetWObjArgument();
if (myWObjArgument != null)
{
Logger.AddMessage(new LogMessage("WObjArgument Name: '" + myWObjArgument.Name + "' Value: '" + myWObjArgument.Value + "'"));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}