Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MakeProgram - how to change the name & extension of the output file?
I'm generating robot program files via the RoboDK API using "MakeProgram". How do I change the name and the extension of the output file?

The code I use below outputs the program 'myProgram' as the file ''. I would like to change the filename to e.g. '' or 'myProgram_2.txt', without changing the name of the program itself:

from robolink import *    # RoboDK API
from robodk import *      # Robot toolbox
RDK = Robolink()

myProgramItem = RDK.Item('myProgram',ITEM_TYPE_PROGRAM) # Get the program item named 'myProgram'
myProgramItem.MakeProgram('',RUNMODE_MAKE_ROBOTPROG) # Export 'myProgram' to file.
I think you could do something like that before generating the program to change the name:


But for the extension, it's coded in the post-processor. 
So either you modify the post or you add a python command to your macro to get the file generated and change the extension. 100% sure it can be done.
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel

Thanks, that does the trick! Rename program, export file, then rename program back to its original name.


Users browsing this thread:
1 Guest(s)