Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regarding RunProgram
#1
def RunProgram(self, fcn_param, wait_for_finished = False):

"""Run a program (start a program). If the program exists in the RoboDK station it has the same behavior as right clicking a and selecting Run (or Run Python script for Python programs).
        When generating a program offline (Offline Programming), the program call will be generated in the program output (RoboDK will handle the syntax when the code is generated for a specific robot using the post processor).
                
        :param fcn_param: program name and parameters. Parameters can be provided for Python programs available in the RoboDK station as well.
        :type fcn_param: str
        :param bool wait_for_finished: Set to True to block execution during a simulation until the program finishes (skipped if the program does not exist or when the program is generated)


What do you mean by this parameters?Can you provide an example for this? Is that global variables like 'APPROACH' ,'RADIUS' etc?
#2
What program are you trying to call?

When you use RunProgram in simulation mode, it will trigger that program if you have it available in your RoboDK station. If that program you triggered is a Python program, you can collect the parameters as if you passed them as arguments (like command line arguments).

When you generate code for your robot controller, the parameters will be passed as arguments. Usually the post processor will handle the way these parameters are passed (some controllers do not allow passing parameters).
#3
(04-03-2020, 09:16 PM)Albert Wrote: What program are you trying to call?

When you use RunProgram in simulation mode, it will trigger that program if you have it available in your RoboDK station. If that program you triggered is a Python program, you can collect the parameters as if you passed them as arguments (like command line arguments).

When you generate code for your robot controller, the parameters will be passed as arguments. Usually the post processor will handle the way these parameters are passed (some controllers do not allow passing parameters).

Hi Albert, 

I was hoping you could elaborate on how exactly you pass multiple arguments into a python program through the RunProgram call (now using the RunCode method). I am using the C# api to execute an existing python script. 

The RunCode documentation asks for a list of strings as its input. In the code below, the line "SCRIPT.RunCode(inputs)" gives me the error "Cannot convert List<string> to 'string' ". 
Code:
               RoboDK.Item SCRIPT = RDK.getItem(scriptName);
               List<string> inputs = new List<string>();
               inputs.Add(numEdges);
               inputs.Add(radius);
               inputs.Add(TCPspeed);
               SCRIPT.RunCode(inputs);

My current work around is assembling the inputs into a single string through the code below and passing that into the python script. The python script then splits the string based on space delamination; however, it would be nice to use "sys.argv[n]" call in the python code to gather inputs. 

Code:
               RoboDK.Item SCRIPT = RDK.getItem(scriptName);
               string inputs = numEdges + " " + radius + " " + TCPspeed;
               SCRIPT.RunCode(inputs);

Run Code Reference 
https://robodk.com/doc/en/PythonAPI/robo...em.RunCode

Any help is appreciated, or just let me know if you need more information! 
Trevor
  




Users browsing this thread:
1 Guest(s)