03-12-2025, 02:58 PM
I'm having difficulties generating Robot Program Files through the RoboDK API in headless mode.
Goal:
Code for Starting RoboDK Headless & Generating the Program
Has anyone encountered this issue before? Could it be a permissions issue, file path problem, or something missing when running in headless mode?
Also, If someone could explain the difference between the MakeProg and MakeProgram commands.
Any insights would be greatly appreciated!
Goal:
- Run RoboDK headless.
- Send a request through the API (localhost for now but later remotely) to generate a robot program based on selected parameters.
- I have a station with a sequence.py script that contains predefined robot movements.
- When RoboDK is open and I run my MakeProg (second code bellow), it works fine.
- However, when I run my program to start RoboDK in headless mode and execute the same file, I receive: Program generated: OK
But no file was generated
- Idea is to later send the program written in python through the API and my RoboDK headless generates the Robot program for it.
Code for Starting RoboDK Headless & Generating the Program
Code:
from robodk.robolink import * # RoboDK API
import time
# Start RoboDK in headless mode and load the station
RDK = Robolink(args=['-NOUI','-SKIPINI'])
station = RDK.AddFile("C:/Users/dantunes/Desktop/Projects/API_Test.rdk")
RDK.setActiveStation(station)
print(RDK.ActiveStation().Name())
# Allow time for RoboDK to fully load
time.sleep(5)
stations = RDK.getOpenStations()
# Print the station names
if stations:
print("Open Stations in RoboDK:")
for station in stations:
print(f"- {station.Name()}")
else:
print("No open stations found in RoboDK.")
Code:
from robodk.robolink import * # RoboDK API
import time
# Connect to the running RoboDK instance
RDK = Robolink()
# Wait a bit to ensure connection is established
time.sleep(2)
print(RDK.ActiveStation().Name())
# Set the output path for generated robot programs
RDK.Command("PathPrograms", "C:/Users/dantunes/Desktop/Projects/")
# Set the post-processor for the program
RDK.Command("PostProcessor", "Epson_RC.py")
print("Generating robot program for 'Sequence'...")
file = RDK.Command("MakeProg", "Sequence")
print(f"Program generated: {file}")
RDK.Finish()
print("Disconnected from RoboDK.")
Has anyone encountered this issue before? Could it be a permissions issue, file path problem, or something missing when running in headless mode?
Also, If someone could explain the difference between the MakeProg and MakeProgram commands.
Any insights would be greatly appreciated!