Dialog Tutorial

I've been using the Quick Commands and so long as I put the complete GCODE along with the associated @dialogButton it works just fine. However if I try to call a defined "replacement" that contains both a dialog and GCODE (GCODE is the first lines of the replacement) the dialog in the replacement never gets executed.

I put in the example for "levelling" on https://www.repetier-server.com/dialog-tutorial/ just to see if any of the dialogs would work and I couldn't get any of them to show. So from the quick command I got the G28 but from that point the logic never continued on to level1.

Is there some special syntax required because it certainly doesn't like the ^level1$ styled routine tags. Just use level1 at least gets something to partially work.

My goal is to have have a filament loading and unloading, with looped selectable purging and then exit. I have the load and unload working but thats it.

Mel

Comments

  • Hello Mel.
    We got a new way to define functions by our new Language starting with version 1.2.0
    you don't have to define replacements anymoe if you want to trigger a function. 
    What you want is a script like like this:

    @func MBLDriveTo x y
        G1 Z{{fixed(min(perm.manBedLevZhop + perm.manBedLevZoffset, config.move_z_max),3)}} F{{fixed(config.speed_z_per_minute,0)}}
        G1 X{{fixed(local.x,2)}} Y{{fixed(local.y,2)}} F{{fixed(config.speed_xy_per_minute,0)}}
        G1 Z{{fixed(local.manBedLevZoffset,3)}}  F{{fixed(config.speed_z_per_minute,0)}}
        @call MBLCartesian

    @func MBLDriveToDelta angle dist
        G1 Z{{fixed(min(perm.manBedLevZhop + perm.manBedLevZoffset, config.move_z_max),3)}} F{{fixed(config.speed_z_per_minute,0)}}
        G1 X{{fixed(local.dist*cos(to_rad(local.angle)),2)}} Y{{fixed(local.dist*sin(to_rad(local.angle)),2)}} F{{fixed(config.speed_xy_per_minute,0)}}
        G1 Z{{fixed(local.manBedLevZoffset,3)}}  F{{fixed(config.speed_z_per_minute,0)}}
        @call MBLDelta

    @func MBLStart
        G28
        @if {{config.bed_shape == "circle"}}
            @call MBLDelta
        @else
            @call MBLCartesian
        @endif

    @func MBLCartesian
        @set local.middleX {{(config.bed_x_min + config.bed_x_max) / 2}}
        @set local.middleY {{(config.bed_y_min + config.bed_y_max) / 2}}
        @dialogStart "Offset x and y are the distances of the points to the bed border. If you measure with a piece of paper, you should level for z height 0. If you have a block of known height that you push between bed and nozzle, enter the object height instead. With z hop printer raises head when traveling between the points." "Manual Bed Leveling"
            @dialogIcon '<svg version="1.1" viewBox="-10 0 1011 1000">   <path fill="currentColor" d="M494.27 425.45c41.6104 33.8623 68.2715 54.5059 88.3301 102.375c24.0908 57.4873 18.9805 92.1377 18.25 155.138l-116.069 -0.788086c0.729492 -44.0996 8.93066 -57.5654 -6.57031 -96.8623c-14.5996 -37.0127 -32.8496 -49.6123 -60.5898 -77.9629zM2.91016 800.85l713.939 -787.5l81.7607 85.0508l-534.36 581.175h726.05v121.274h-987.39z"></path></svg>'
            @dialogInputDouble "Offset X [mm]" perm.manBedLevXoffset default({{get("perm","manBedLevXoffset","20")}}) min(0) max({{local.middleX}})
            @dialogInputDouble "Offset Y [mm]" perm.manBedLevYoffset default({{get("perm","manBedLevYoffset","20")}}) min(0) max({{local.middleY}})
            @dialogInputDouble "Measure Z at [mm]" perm.manBedLevZoffset default({{get("perm","manBedLevZoffset","0")}}) min(0) max({{config.move_z_max}})
            @dialogInputDouble "Z Hop [mm]" perm.manBedLevZhop default({{get("perm","manBedLevZhop","5")}}) min(0) max({{config.move_z_max}})
            @dialogButton "Top-Left" "@call MBLDriveTo {{config.bed_x_min + perm.manBedLevXoffset}} {{config.bed_y_max - perm.manBedLevYoffset}}"
            @dialogButton "Top-Right" "@call MBLDriveTo {{config.bed_x_max - perm.manBedLevXoffset}} {{config.bed_y_max - perm.manBedLevYoffset}}"
            @dialogButton "Center" "@call MBLDriveTo {{(config.bed_x_min + config.bed_x_max) / 2}} {{(config.bed_y_min + config.bed_y_max) / 2}}"
            @dialogButton "Bottom-Left" "@call MBLDriveTo {{config.bed_x_min + perm.manBedLevXoffset}} {{config.bed_y_min + perm.manBedLevYoffset}}"
            @dialogButton "Bottom-Right" "@call MBLDriveTo {{config.bed_x_max - perm.manBedLevXoffset}} {{config.bed_y_min + perm.manBedLevYoffset}}"
            @dialogButton "Finished"

    @func MBLDelta
        @dialogStart "Offset is the distance of the points to the bed border. If you measure with a piece of paper, you should level for z height 0. If you have a block of known height that you push between bed and nozzle, enter the object height instead. With z hop printer raises head when traveling between the points." "Manual Bed Leveling"
            @dialogIcon '<svg version="1.1" viewBox="-10 0 1011 1000">   <path fill="currentColor" d="M494.27 425.45c41.6104 33.8623 68.2715 54.5059 88.3301 102.375c24.0908 57.4873 18.9805 92.1377 18.25 155.138l-116.069 -0.788086c0.729492 -44.0996 8.93066 -57.5654 -6.57031 -96.8623c-14.5996 -37.0127 -32.8496 -49.6123 -60.5898 -77.9629zM2.91016 800.85l713.939 -787.5l81.7607 85.0508l-534.36 581.175h726.05v121.274h-987.39z"></path></svg>'
            @dialogInputDouble "Offset [mm]" perm.manBedLevXoffset default({{get("perm","manBedLevOffset","20")}}) min(0) max({{config.bed_radius / 2}})
            @dialogInputDouble "Measure Z at [mm]" perm.manBedLevZoffset default({{get("perm","manBedLevZoffset","0")}}) min(0) max({{config.move_z_max}})
            @dialogInputDouble "Z Hop [mm]" perm.manBedLevZhop default({{get("perm","manBedLevZhop","5")}}) min(0) max({{config.move_z_max}})
            @dialogButton "Tower A" "@call MBLDriveToDelta 210 {{config.bed_radius - perm.manBedLevOffset}}"
            @dialogButton "Tower B" "@call MBLDriveToDelta 330 {{config.bed_radius - perm.manBedLevOffset}}"
            @dialogButton "Tower C" "@call MBLDriveToDelta 90 {{config.bed_radius - perm.manBedLevOffset}}"
            @dialogButton "Center" "@call MBLDriveToDelta 0 0"
            @dialogButton "Finished"

    @if {{job.running}}
        @error "Manual bed leveling during print not possible!"
        @dialogStart "This wizard is meant for manual bed leveling. It will offer buttons to quickly move to the edges and center. At first it will home, so please make sure bed is free of obstacles." "Manual Bed Leveling"
        @dialogIcon '<svg version="1.1" viewBox="-10 0 1011 1000">   <path fill="currentColor" d="M494.27 425.45c41.6104 33.8623 68.2715 54.5059 88.3301 102.375c24.0908 57.4873 18.9805 92.1377 18.25 155.138l-116.069 -0.788086c0.729492 -44.0996 8.93066 -57.5654 -6.57031 -96.8623c-14.5996 -37.0127 -32.8496 -49.6123 -60.5898 -77.9629zM2.91016 800.85l713.939 -787.5l81.7607 85.0508l-534.36 581.175h726.05v121.274h-987.39z"></path></svg>'
        @dialogButton "Bed cleared - Start" "@call MBLStart"
        @dialogButton "Cancel"

    Copy this and paste it in a Wizard or a QuickCommand. 
    This script does give you plenty of options to level your Bed correctly.

    Thank you for reminding us to update our tutorial, we will add this code with some explanation soon to our docs.


  • Wow...C++ is taken so you going to call this R++? LOL

    Going to take me a bit to wade through all that syntax...

    I assume you're getting a lot of those variables from the items configuration that have been defined.

    Hence I assume there's a master list of those someplace?

    So something that references config.bed_radius, "config." points to the current printer configuration and "bed_radius" is the variable within that configuration...?

    However, since I don't see a global defined anywhere, where exactly is "perm.manBedLevOffset" getting the data from?

    Lastly once the subroutine "@func MBLDelta" is started, am I safe to assume it will stay in that function until the "Finished" option is selected? So I could select TowerA, TowerC, TowerA, TowerB and keep going between the towers until I selected the "Finished" option?

    Sorry for all the questions, just trying to wrap my head around the concept...

    Mel

  •  
    Hello, 

    "Hence I assume there's a master list of those someplace?"
    Yes, you can find all available instructions, variable typs and functions in the manual.

    "So something that references config.bed_radius, "config." points to the current printer configuration and "bed_radius" is the variable within that configuration...?"
    Yes. config variables are values from the current printer configuration in the server. You can find a list in the manual.

    "However, since I don't see a global defined anywhere, where exactly is "perm.manBedLevOffset" getting the data from?"
    The first time this variable will show up in the code is in the line :
    @dialogInputDouble "Measure Z at [mm]" perm.manBedLevZoffset default({{get("perm","manBedLevZoffset","0")}}) min(0) max({{config.move_z_max}})
    Dialog components will define a variable if its not defined jet.

    Lastly once the subroutine "@func MBLDelta" is started, am I safe to assume it will stay in that function until the "Finished" option is selected? So I could select TowerA, TowerC, TowerA, TowerB and keep going between the towers until I selected the "Finished" option?
    Yes, this is a recursive call and the Finished Button is for determination.


  • See in manual -> Computed Variables for possible variable names and what is defined.
  • Thanks for the clarification, very much appreciated...off to parse the manual now!

    Mel
Sign In or Register to comment.