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

Append Lines to Code

#1
Good morning,

I would like to append a few lines of code to the output file of the postprocessor (kuka krc4).
Pretty sure this can be done with a relatively simple .append method (code has to sit at the very end of the output file *.src)

I have found no example in the roboDK documentation and since I am far from being a programmer I would be grateful for a little help.

best regards
Hermann
#2
You can easily do this using the user interface by using a program call instruction at the end of your program. This allows you to add one or more custom lines of code in your program:
//www.sinclairbody.com/doc/en/Robot-Programs...nsProgCall

Alternatively, if you need this for all your programs we can help you customize a post processor.
#3
Thank you,

我怎么方法如果我想添加某些李nes of code at the very end of the output file?
#4
If you add a "Program Call" at the end of your program, you can select the dropdown menu and choose "Insert Code" and type in the code you would like to see.
This is the easiest method and it does not require any coding.

Jeremy
Find useful information about RoboDK and its features by visiting our2022世界杯32强赛程表时间 and by watching tutorials on ourYoutube Channel.


#5
I understand but I would like to standardize this via a postprocessor.

This is what I got so far.

def RunCode(self, code, is_function_call=False):
"""Adds code or a function call"""

# add counter attribute if this is the first call to RunCode
if not hasattr(self, "M51_counter"):
self.M51_counter = 0

if "M_RunCode(50)" in code:
# filtering M50
self.addline("\n")
self.addline("laser on")
self.addline("\n")

return

elif "M_RunCode(51)" in code:

# ignore the first M51 call
if self.M51_counter > 0:
# In program events, we'll be filtering M50 by M_RunCode by default
self.addline("\n")
self.addline("laser off")
self.addline("\n")


return

# always increase the counter, even if it was 0
self.M51_counter += 1
return

if "M_RunCode(30)" in code:

self.addline("")

return

(Indentations might be displayed not correctly)


As you can see this "uses" the M-Codes for adding new lines.
我只是想添加行不”劫持ing" the M-Codes at the very end of the ouput file.
#6
ok, then do it. XD
What you created so far looks good. What is the issue exactly?
What is the result from the code you just posted.

To use the M-Code you need to start from an NC (G-code) file and it needs to have an M-Code at the end.
Is it your situation?
If so simply capture the code and go for a addline.
Find useful information about RoboDK and its features by visiting our2022世界杯32强赛程表时间 and by watching tutorials on ourYoutube Channel.


#7
Well...I might not be a programmer...but it will get done (with a little help ;) )

Yes....the capturing of the M-Code works just fine.

What I want to do is add the following textcluster at the end of each output file. This textcluster is not linked to any M-Code and should just be printed "as is".
Of course I could just manually copy&paste thist cluster, but...you know...that would be unacceptable ;)



DEF laser_on()

;FOLD OUT 13 'Laser bereit (standby)' State=TRUE ;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:13, 3:Laser bereit (standby), 5:TRUE, 6:
$OUT[13]=TRUE
;ENDFOLD
;FOLD OUT 14 'Laser (Steuerung) ein' State=TRUE ;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:14, 3:Laser (Steuerung) ein, 5:TRUE, 6:
$OUT[14]=TRUE
;ENDFOLD
;FOLD OUT 267 'Absaugung ein' State=TRUE ;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:267, 3:Absaugung ein, 5:TRUE, 6:
$OUT[267]=TRUE
;ENDFOLD

;FOLD OUT 266 'Sauerstoff' State=TRUE ;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:266, 3:Sauerstoff, 5:TRUE, 6:
$OUT[266]=TRUE
;ENDFOLD
laser_ein(3,800,#schneiden)
;FOLD WAIT Time=3 sec;%{PE}%R 8.3.38,%MKUKATPBASIS,%CWAIT,%VWAIT,%P 3:3
WAIT SEC 3
;ENDFOLD
laser_aus()
laser_ein(1,1000,#schneiden)



END



DEF laser_off()

;FOLD OUT 266 'Sauerstoff' State=FALSE CONT;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:266, 3:Sauerstoff, 5:FALSE, 6:CONTINUE
CONTINUE
$OUT[266]=FALSE
;ENDFOLD
;FOLD OUT 267 'Absaugung ein' State=FALSE ;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:267, 3:Absaugung ein, 5:FALSE, 6:
$OUT[267]=FALSE
;ENDFOLD
;FOLD OUT 14 'Laser (Steuerung) ein' State=FALSE ;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:14, 3:Laser (Steuerung) ein, 5:FALSE, 6:
$OUT[14]=FALSE
;ENDFOLD
;FOLD OUT 13 'Laser bereit (standby)' State=FALSE ;%{PE}%R 8.3.38,%MKUKATPBASIS,%COUT,%VOUTX,%P 2:13, 3:Laser bereit (standby), 5:FALSE, 6:
$OUT[13]=FALSE
;ENDFOLD
;FOLD LIN P13 Vel=0.5 m/s CPDAT10 Tool[2]:Schneidkopf Base[0];%{PE}%R 8.3.38,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:P13, 3:, 5:0.5, 7:CPDAT10
$BWDSTART=FALSE
LDAT_ACT=LCPDAT10
FDAT_ACT=FP13
BAS(#CP_PARAMS,0.5)
LIN XP13
;ENDFOLD

pv_korrektur=false



END
#8
Oh, shouldn't that be added in the header instead?

You should find a "CUSTOM_HEADER" section in the post where you could add custom code like this and it will always be added to the program.
I'm not an expert with KRL but with most language I know, adding it in the header should work.

Jeremy
Find useful information about RoboDK and its features by visiting our2022世界杯32强赛程表时间 and by watching tutorials on ourYoutube Channel.






Users browsing this thread:
1 Guest(s)