Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Basics of Program Event Input and Output

Hi all,

I'm working my way through the documentation and have a few very simple questions that I can't find an explict answer to in the documentation. It's probably so simple that it was never documented but I'm having a really tough time figuring it out and it's consuming more time than I currently have. :(

I'm trying the program events for 3D printing, and when the E Value appears in the Gcode the program event "Call Extruder('EValue')" appears in the instructions.
I then want to create a python script that to begin with should just print the EValue of that specific Program Event or save it to at text file on the Desktop.

So for example if I have a Robot Program with the instructions list:
MoveL 1
Call Extruder(5)
MoveL 2
Call Extruder(10)

I want it to print 5 somewhere after the first move and then 10 after the second move. How do I handle the input from the program event? And where does it print to? How could I save the input to a text file? The Problem I'm having is less with the Python commands and more with how they interact with the RoboDK Program.
Dear all,

I've made some more progress, adding Instruction Calls and such. But I'm still struggling with the automatically created Instructions to call functions, such as Run_MCode(%2) and Extruder(%1). When I use them like this the instructions then call for example the function Run_Mcode(104 S200) or similar. So far so good, however this is then interpreted as a name of the function to be called not a function with variable input, so "104 S200" is part of the name. For the MCodes this could be solved by writing up scripts for all the Codes used but for the Extruder where we have an infinite number of possibilities this cannot be done.
So my question is the following is there a way to have the argument in the parenthesis recognized as variable?
If not, a workaround could be to introduce 2 Function calls and have the variable in the name of the first and is simply skipped during program execution and have the second read the name of the previous instruction to then further process the variable. In the examples I only found ways to call the items by name or index number. Is there a way to call the currently active instruction or the previous?

Best regards
Found a mistake:
I had previously modified the postprocessor and it intercepted the Extruder() function calls, it works with the standard post-processor. However I still don't know how to get the input from the Function Call i.e. Extruder(10) into the function as internal variable.
Hi Patrick,

The simplest way would be to remove the starting "Extruder(" characters and the last ")" character. Then, convert it to a number.

For example:
code = "Extruder(123)"
value = float(code[9:-1])


Users browsing this thread:
1 Guest(s)