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

MakeProgram - how to change the name & extension of the output file?

#1
Question
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 'myProgram.py'. I would like to change the filename to e.g. 'myProgram_1.py' or 'myProgram_2.txt', without changing the name of the program itself:

Code:
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.
#2
I think you could do something like that before generating the program to change the name:

Code:
myProgramItem.setName(“新名称”)

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 ourOnline Documentationand by watching tutorials on ourYoutube Channel.


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

Maarten




Users browsing this thread:
1 Guest(s)