Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add Instructions to Program in C# API
#1
I am looking to modify an existing program in RoboDK through the use of the C# RoboDK API. I have found that I can get the list of instructions with the InstructionList function call (though the Instruction types do not seem to line up to the INS_TYPE_* definitions). I am looking to add a new instruction at some position in the program and, while there appears to be a method for setting a movement instruction, the API seems incomplete as to adding other types of instructions. My first objective would be to add a set speed command to change the speed of the program however this does not seem to be available. setInstruction only seems to allow parameters for movement commands. Can you provide insight into how to insert other commands to an existing program through the API (for example, a speed change half way through the program)?


public void setInstruction(int ins_id, string name, int instype, int movetype, bool isjointtarget, Mat target, double[] joints)
        {
            link._check_connection();
            link._send_Line("Prog_SIns");
            link._send_Item(this);
            link._send_Int(ins_id);
            link._send_Line(name);
            link._send_Int(instype);
            if (instype == INS_TYPE_MOVE)
            {
                link._send_Int(movetype);
                link._send_Int(isjointtarget ? 1 : 0);
                link._send_Pose(target);
                link._send_Array(joints);
            }
            link._check_status();
        }
#2
If you simply need to change the speed you could use the setSpeed function:
Code:
...
program.MoveJ(...)
...
program.setSpeed(new_speed)
...

You can also use setParam to get or set instruction data. This method requires manipulating JSON strings. This example shows the concept:
https://robodk.com/doc/en/PythonAPI/exam...structions
If you set the instruction id to -1 or you index passed the last instruction it will add the instruction as a new instruction (instead of modifying an existing instruction). You can also reorder instructions if you need. This example shows the concept:
C:\RoboDK\Library\Macros\Reorganise_Prog.py
  




Users browsing this thread:
1 Guest(s)