######################################################################
#
# Macro Name    : c://blast_tutorial/02_auto_rmc_patterns.tcl
#
# Version       : Surpac Vision V5.2-B Beta
#
# Creation Date : Wed Jan 11 15:26:40 2006
#
# Description   : Peter Esdale
#
######################################################################

set status [ SclFunction "GEOLOGY DATABASE DISCONNECT" {} ]

set status [ SclFunction "EXIT GRAPHICS" {
  frm00108={
    {
      exit_mode="E"
    }
  }
}]

set form {
  GuidoForm form_1 {
    -default_buttons
    -label "Modify Blast Defaults"
    GuidoPanel panel_1 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_1 {
      -label ""
      -height 14
      -width 70
        GuidoTextArea text_1 {
        -format none
        -linewrap true
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "

The following section of the tutorial demonstrates creating a number of blast patterns using the auto spacing and burden from polygons option

Please note that the polygon file must be in the currently active layer - i.e. drag the polygon file into graphics last

First recall the pit pickup and Rock Mass Classification (RMC) polygon files and have a look at the data.

When the macro pauses click in graphics to continue

After having a look at each form, apply it to continue

"
        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "RECALL ANY FILE" {
  file="bench960_950.str"
  mode="openInNewLayer"
}]

set status [ SclFunction "RECALL ANY FILE" {
  file="rmc_960.str"
  mode="openInNewLayer"
}]

set status [ SclFunction "ZOOM IN" {} ]

########### pause here, wait for user response (say enter key), then proceed

puts ""
puts ""
puts ""
puts ""
puts "Click in graphics to continue."
puts ""
puts ""

SclPause

 set form {
  GuidoForm form_2 {
    -default_buttons
    -label "Set up RMC polygons"
    GuidoPanel panel_2 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_2 {
      -label ""
      -height 10
      -width 70
        GuidoTextArea text_2 {
        -format none
        -linewrap true
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
On the following \"Blast Pattern Design\" form note the blast details that have been selected and the option to modify burden and spacing by polygon.

Click on the tab \"Hole Settings\" to inspect options selected for hole bearing, angle, length and labelling.

Note: the generation of the blast holes may take a little time depending on the speed of your computer.
"

        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "BLAST RECTANGLE" {
  window_drag={
    {
      winx1="-0.326"
      winy1="0.341"
      winx2="0.167"
      winy2="-0.338"
      objectx1="57.857"
      objecty1="815.750"
      objectz1="960.000"
      objectx2="275.963"
      objecty2="661.693"
      objectz2="960.000"
    }
  }
  world_drag=table { objectx objecty objectz dx dy dz function } {
    { "238.514" "674.544" "960.134" "-31.442" "761.003" "960.000" "rotate" }
    { "167.825" "761.456" "960.134" "47.585" "-73.654" "0.000" "drag" }
    { "0.000" "0.000" "0.000" "0.000" "0.000" "0.000" "complete" }
  }
  frm01125={
    {
      _action=display
      x="105.442"
      y="588.038"
      height="154.057"
      width="288.106"
      angle="-31.442"
      geometry="Rectangular"
      order="Regular"
      autoburden="true"
      classfield="D1"
      rockclasses=table { rockClass rockBurden rockSpacing rockSubdrill } {
        { "Laterite" "6" "5" "2.2" }
        { "Lumpy Laterite" "2" "1.8" "2.1" }
        { "Clay" "1.5" "2" "1" }
        { "MNCL" "4" "3" "1.26" }
        { "6x6.5" "4" "6.5" "0.7" }
        { "4x5" "4" "5" "0.8" }
        { "5x6" "4" "6" "0.9" }
        { "Basalt Fresh" "2.5" "2.5" "0.6" }
      }
      size_method="Burden and Spacing"
      burden_inp="10"
      spacing_inp="5"
      collar_el="Fixed"
      fixed_el="960"
      hole_length="Set Elevation"
      set_el="955"
      bearing="0"
      dip="-90"
      diameter="0.1"
      pattern_id="BP1"
      rig="Rig-1"
      blasting_method="row by row"
      ground_water_level="0"
      prefix=""
      class_prefix_check="No"
      suffix=""
      start="1"
      row_check="No"
      pad_check="No"
    }
  }
}]

set form {
  GuidoForm form_3 {
    -default_buttons
    -label "Delete unwanted holes"
    GuidoPanel panel_3 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_3 {
      -label ""
      -height 5
      -width 40
        GuidoTextArea text_3 {
        -format none
        -linewrap true
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
Next delete all holes outside the area of interest.
"

        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "BLAST DEL OUTSIDE SEGMENT" {
  select_point={
    {
      winx="-0.201"
      winy="0.568"
      objectx="130.215"
      objecty="791.784"
      objectz="960.134"
    }
  }
}]

set status [ SclFunction "ERASE DESC" {
  frm00089={
    {
      range1=""
      range2=""
      range3=""
      textalignment="<"
      legend_location="no legend"
      layer_name="blast hole layer"
    }
  }
}]

set status [ SclFunction "BLAST DELETE HOLE" {
  select_point={
    {
      winx="-0.244"
      winy="-0.372"
      objectx="122.512"
      objecty="703.967"
      objectz="960.134"
    }
  }
}]

set status [ SclFunction "ERASE DESC" {
  frm00089={
    {
      range1=""
      range2=""
      range3=""
      textalignment="<"
      legend_location="no legend"
      layer_name="blast hole layer"
    }
  }
}]

set form {
  GuidoForm form_4 {
    -default_buttons
    -label "Save and load to database"
    GuidoPanel panel_4 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_4 {
      -label ""
      -height 8
      -width 70
        GuidoTextArea text_4 {
        -format none
        -linewrap true
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
Next save the string file and load the holes to the blast database.

Note: if you wish to keep a copy of the blast holes in string file format, you need to save the string file first, because after loading a blast pattern to the database, the string layer is deleted and holes from the database displayed. This is to avoid having two copies of the blast pattern in graphics at the one time, which could potentially contain conflicting information after an editing operation.
"

        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}

set status [ SclFunction "SAVE FILE AS" {
  output_file="bp1.str"
  output_type="Surpac String Files"
  output_filenames=""
  Surpac={
    Purpose=""
    range=""
    FileFormat="text"
    ForceValidation="true"
    ForceCompatibility="true"
  }
}]

set status [ SclFunction "BLAST OPEN DATABASE" {
  frm10010={
    {
      dbname="blast_tutorial.ddb"
    }
  }
}]

set status [ SclFunction "CLEAR DATABASE" {
  frm77013={
    {
      sessionCombo="blast_tutorial"
    }
  }
  frm10060={
    {
      conf="Y"
    }
  }
}]

set status [ SclFunction "GEOLOGY DATABASE DISCONNECT" {} ]

set status [ SclFunction "BLAST LOAD TO DATABASE" {
  frm10010={
    {
      dbname="blast_tutorial.ddb"
    }
  }
  frm01126={
    {
      _action=display
      load_charging_data="Y"
      charging_table_name="charge"
      load_sample_data="N"
      increment_method="continuous"
      sampling_method="single sample"
      report_file="bp1"
      report_format=".not - Surpac Note File"
    }
  }
}]

set status [ SclFunction "CHECK DATABASE CONNECTED" {} ]

set status [ SclFunction "DRILLHOLE ATTRIBUTES" {
  trace_colour="forest green"
  trace_thickness="1"
  legend_location="no legend"
  table=""
  field=""
  tick_mark_weight="1"
  rescale="true"
  add_constraint="true"
  cylinder_style="no cylinders"
  cylinder_radius="0.000"
  cylinder_maximum="0.0"
  show_collars="true"
  frm00012={
    {
      cons={
        {
          field=""
          operator="="
          value=""
        }
      }
    }
  }
}]

set status [ SclFunction "DRILLHOLE COLLARS" {
  show_collars="true"
  collar_marker="(+)"
  collar_marker_size="0.5"
  position="along path"
  num_rows="0"
}]

set status [ SclFunction "DRILLHOLE GEOLOGY" {
  num_rows="0"
}]

set status [ SclFunction "DRILLHOLE LABELS" {
  tick_length="1.0"
  num_rows="0"
}]

set status [ SclFunction "DRILLHOLE GRAPHS" {
  num_rows="0"
}]

set status [ SclFunction "DRILLHOLE DEPTH MARKERS" {
  position="left"
  offset="5.0"
  decimals="2"
  use_styles="false"
  colour=""
  font_style="Default"
  font_size="1.000"
  font_units="oru"
  alignment="right"
  major="10.0"
  minor="0.0"
  display="false"
  major_length="3.0"
  minor_length="1.0"
}]

set status [ SclFunction "DRILLHOLE APPARENT DIP MARKERS" {
  num_rows="0"
}]

set status [ SclFunction "ZOOM IN" {} ]

set status [ SclFunction "ZOOM IN" {} ]

set form {
  GuidoForm form_5 {
    -default_buttons
    -label "Set up RMC polygons"
    GuidoPanel panel_5 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_5 {
      -label ""
      -height 7
      -width 70
        GuidoTextArea text_5 {
        -format none
        -linewrap true
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
Next a new RMC string polygon file for the subsequent bench down is recalled to graphics for a second blast pattern to be designed.

Once again the pattern is loaded to the blast database, but this time without saving the string file.
"

        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}
set status [ SclFunction "RECALL ANY FILE" {
  file="rmc_955.str"
  mode="openInNewLayer"
}]

########### pause here, wait for user response (say enter key), then proceed

puts ""
puts ""
puts ""
puts ""
puts "Click on graphics to continue."
puts ""
puts ""

SclPause

set status [ SclFunction "ZOOM IN" {} ]

set status [ SclFunction "ZOOM IN" {} ]

set status [ SclFunction "BLAST RECTANGLE" {
  window_drag={
    {
      winx1="-0.092"
      winy1="-0.300"
      winx2="0.316"
      winy2="-0.920"
      objectx1="181.770"
      objecty1="704.486"
      objectz1="955.000"
      objectx2="272.096"
      objecty2="634.060"
      objectz2="955.000"
    }
  }
  world_drag={
    {
      objectx="0.000"
      objecty="0.000"
      objectz="0.000"
      dx="0.000"
      dy="0.000"
      dz="0.000"
      function="complete"
    }
  }
  frm01125={
    {
      _action=display
      x="181.77"
      y="634.06"
      height="70.426"
      width="90.327"
      angle="0"
      geometry="Rectangular"
      order="Regular"
      autoburden="true"
      classfield="D1"
      rockclasses=table { rockClass rockBurden rockSpacing rockSubdrill } {
        { "Laterite" "6" "5" "2.2" }
        { "Lumpy Laterite" "2" "1.8" "2.1" }
        { "Clay" "1.5" "2" "1" }
        { "MNCL" "4" "3" "1.26" }
        { "6x6.5" "4" "6.5" "0.7" }
        { "4x5" "4" "5" "0.8" }
        { "5x6" "4" "6" "0.9" }
        { "Basalt Fresh" "2.5" "2.5" "0.6" }
      }
      size_method="Burden and Spacing"
      burden_inp="10"
      spacing_inp="5"
      collar_el="Fixed"
      fixed_el="955"
      hole_length="Set Elevation"
      set_el="950"
      bearing="0"
      dip="-90"
      diameter="0.1"
      pattern_id="BP2"
      rig="Rig-1"
      blasting_method="row by row"
      ground_water_level="0"
      prefix=""
      class_prefix_check="No"
      suffix=""
      start="1"
      row_check="No"
      pad_check="No"
    }
  }
}]

set status [ SclFunction "ERASE DESC" {
  frm00089={
    {
      range1=""
      range2=""
      range3=""
      textalignment="<"
      legend_location="no legend"
      layer_name="blast hole layer"
    }
  }
}]

set status [ SclFunction "BLAST LOAD TO DATABASE" {
  frmBlastLoadToDatabase={
    {
      _action="apply"
    }
  }
  frm01126={
    {
      _action=display
      load_charging_data="Y"
      charging_table_name="charge"
      load_sample_data="N"
      increment_method="continuous"
      sampling_method="single sample"
      report_file="bp2"
      report_format=".not - Surpac Note File"
    }
  }
  frm00121={
    {
      _action="apply"
    }
  }
}]

########### pause here, wait for user response (say enter key), then proceed

puts ""
puts ""
puts ""
puts ""
puts "Click on graphics to continue."
puts ""
puts ""

SclPause

set form {
  GuidoForm form_6 {
    -default_buttons
    -label "Set up RMC polygons"
    GuidoPanel panel_6 {
    -layout BoxLayout Y_AXIS
      GuidoTextArea gainfocus {
      -visible true
      -default "This text area is here to remove focus and highlighting from the second GuidoTextArea
                This text area must have visible set to true in order to gain focus"
      -height 0
      -width 0
      }
      GuidoLabel space {
      -height 0.5
      }
      GuidoScrollPane scroll_6 {
      -label ""
      -height 12
      -width 70
        GuidoTextArea text_6 {
        -format none
        -linewrap true
        -wrap_style_word true
        -linewrap true
        -input true
        -font_highlight 0 0 0
        -default "
Next a blast with multiple RMC's within the one pattern will be generated.

A new RMC string polygon file, containing multiple RMC codes is recalled to graphics for this blast pattern to be designed.

For this pattern the holes are also renumbered to be in sequential order after the pattern is \"trimmed\".

Note: some editing of holes will be required at the contact zone between different RMC areas, as the burden and spacing conditions can not be honoured at these locations.

"

        }
      }
      GuidoLabel space {
      -height 0.5
      }
    }
  }
}

SclCreateGuidoForm form_handle $form {
}

$form_handle SclRun {
}
set status [ SclFunction "EXIT GRAPHICS" {} ]

set status [ SclFunction "RECALL ANY FILE" {
  file="bench960_950.str"
  mode="openInNewLayer"
}]

set status [ SclFunction "RECALL ANY FILE" {
  file="multiple_rmc_zones.str"
  mode="openInNewLayer"
}]

########### pause here, wait for user response (say enter key), then proceed
# try this

puts ""
puts ""
puts ""
puts ""
puts "Click on graphics to continue."
puts ""
puts ""

SclPause

set status [ SclFunction "BLAST RECTANGLE" {
  window_drag={
    {
      winx1="-0.378"
      winy1="0.418"
      winx2="0.296"
      winy2="-0.532"
      objectx1="61.037"
      objecty1="867.723"
      objectz1="965.000"
      objectx2="359.444"
      objecty2="652.124"
      objectz2="965.000"
    }
  }
  world_drag=table { objectx objecty objectz dx dy dz function } {
    { "286.351" "687.213" "965.067" "-28.798" "831.649" "965.000" "rotate" }
    { "232.448" "800.608" "965.067" "74.356" "-61.216" "0.000" "drag" }
    { "0.000" "0.000" "0.000" "0.000" "0.000" "0.000" "complete" }
  }
  frm01125={
    {
      _action=display
      x="135.393"
      y="590.908"
      height="215.599"
      width="298.406"
      angle="-28.798"
      geometry="Rectangular"
      order="Regular"
      autoburden="true"
      classfield="D1"
      rockclasses=table { rockClass rockBurden rockSpacing rockSubdrill } {
        { "Laterite" "6" "5" "2.2" }
        { "Lumpy Laterite" "2" "1.8" "2.1" }
        { "Clay" "1.5" "2" "1" }
        { "MNCL" "4" "3" "1.26" }
        { "6x6.5" "4" "6.5" "0.7" }
        { "4x5" "4" "5" "0.8" }
        { "5x6" "4" "6" "0.9" }
        { "Basalt Fresh" "2.5" "2.5" "0.6" }
      }
      size_method="Burden and Spacing"
      burden_inp="10"
      spacing_inp="5"
      collar_el="Fixed"
      fixed_el="960"
      hole_length="Set Elevation"
      set_el="955"
      bearing="0"
      dip="-90"
      diameter="0.1"
      pattern_id="BP3"
      rig="Rig-1"
      blasting_method="row by row"
      ground_water_level="0"
      prefix=""
      class_prefix_check="No"
      suffix=""
      start="1"
      row_check="No"
      pad_check="No"
    }
  }
}]

set status [ SclFunction "BLAST DEL OUTSIDE SEGMENT" {
  select_point={
    {
      winx="-0.381"
      winy="0.704"
      objectx="113.229"
      objecty="851.921"
      objectz="960.783"
    }
  }
}]

set status [ SclFunction "BLAST ASSIGN HOLE ID" {
  frm01131={
    {
      _action=display
      renumber_type="All Holes"
      prefix=""
      suffix=""
      start="1"
      pad_check="No"
    }
  }
}]

set status [ SclFunction "ERASE DESC" {
  frm00089={
    {
      range1=""
      range2=""
      range3=""
      textalignment="<"
      legend_location="no legend"
      layer_name="blast hole layer"
    }
  }
}]
set status [ SclFunction "BLAST LOAD TO DATABASE" {
  frmBlastLoadToDatabase={
    {
      _action="apply"
    }
  }
  frm01126={
    {
      _action=display
      load_charging_data="Y"
      charging_table_name="charge"
      load_sample_data="N"
      increment_method="continuous"
      sampling_method="single sample"
      report_file="bp3"
      report_format=".not - Surpac Note File"
    }
  }
  frm00121={
    {
      _action="apply"
    }
  }
}]


puts ""
puts ""
puts ""
puts ""
puts "Macro 02_auto_rmc_patterns.tcl completed."
puts ""
puts ""
