Merging the code of subprogram in the main program- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) +--- Forum: General questions about RoboDK (//www.sinclairbody.com/forum/Forum-General-questions-about-RoboDK) +--- Thread: Merging the code of subprogram in the main program (/Thread-Merging-the-code-of-subprogram-in-the-main-program) |
Merging the code of subprogram in the main program-Mareli-12-14-2021 Hi, I made point follow project for scanning tool. In the program events I am calling python program to get different orientations of the tool on each point. On simulation everything runs fine. I have all the orientation and movements I need. The problem comes when generate the tp program. Instead of rough code I get "call srm1" (srm1 is the name of the python program). I don't need to call sub program. I need to output the real cntent of the srm1 in the main program. 21:J P[2]20% CNT1 ; 22:L P[3]1000mm/secCNT1 ; 23:L P[4]10mm/secFINE; 24:CALL srm1 ; 25:L P[5]10mm/secCNT1 ; 26:L P[6]1000mm/secCNT1 ; 27:L P[7]10mm/secFINE; 28:CALL srm1 ; 29:L P[8]10mm/secCNT1 ; 30:L P[9]1000mm/secCNT1 ; 31:L P[10]10mm/secFINE; 32:CALL srm1 ; Is it possible to avoid the program call and merge the code of the srm1 to the main program code? (Inline subprograms is checked) RE: Merging the code of subprogram in the main program-Albert-12-14-2021 Make sure to rename your subprogram to srm1. On the other hand, this feature does not work with Python subprograms. If you want to embed a Python subprogram, a workaround could be to follow these steps:
RE: Merging the code of subprogram in the main program-Mareli-12-14-2021 The program created with the Quine post is not working for me because it contains fixed positions. ........ #MoveL Pose(222.853, 195.145, 199.228, -11.892, -5.093, -135.023) AutoTarget0 = RDK.AddTarget('AutoTarget 0',robotFrame,robot) AutoTarget0.setPose(Pose(222.853,195.145,199.228, -11.892, -5.093, -135.023)) srm1.MoveL(AutoTarget0,True) SbSRCH1 #MoveL Pose(222.853, 195.145, 199.228, 5.204, 11.844, -136.048) AutoTarget1 = RDK.AddTarget('AutoTarget 1',robotFrame,robot) AutoTarget1.setPose(Pose(222.853,195.145,199.228,5.204,11.844, -136.048)) srm1.MoveL(AutoTarget1,True) ........ The idea is to make incremental movements according to every point of the point follow project. RE: Merging the code of subprogram in the main program-Jeremy-12-15-2021 There's a way to do this, but it will require a bit more Python coding. You will need to create a Python program that modifies the content of the Point Follow Project program every time you reach your srm1 program call. In fact, you need to replace your srm1 with it's actual content (that could be done directly in the srm1 python script). Here's a basic example of how you can modify instructions in a program using Python://www.sinclairbody.com/doc/en/PythonAPI/examples.html#modify-program-instructions Take a look and let me know what you think. I did not open your station. I'm just answering based on your explanation as I'm a bit in a rush. Jeremy |