HTMLDialog Fill inputbox from csv data

Thank-you,

I am separating the code by following your example from the GitHub link.

begin
  path = "C:/MySketchupDialog/"
  # Create a hash of replacement strings from dialog resource files: 
  replacements = {
    :stylesheet => File.read(File.join(path, "stylesheet.css")) ,
    :javascript => File.read(File.join(path, "javascript.js" )) ,
    :json_data  => File.read(File.join(path, "some_data.json"));
    :draw_box  => File.read(File.join(path, "drawBox.rb"))
  }
  html_text = File.read(File.join(path, "dialog.html"))
rescue => err
  # Handle IO errors
else


	@dialog = UI::HtmlDialog.new(
	{
	  :dialog_title => "Dialog Example",
	  :scrollable => true,
	  :resizable => true,
	  :width => 500,
	  :height => 300,
	  :left => 200,
	  :top => 200,
	  :min_width => 150,
	  :min_height => 150,
	  :max_width =>100,
	  :max_height => 50,
	  :style => UI::HtmlDialog::STYLE_DIALOG
	})

  # Insert the replacement file text into the HTML and pass to dialog:
  @dialog.set_html( html_text % replacements )
  @dialog.show
end

I have a separate file for the drawBox.rb but unsure where to call it.

drawBox.rb file

require "sketchup.rb"

dialog.add_action_callback("getUserInput"){|action_context,nm, user_input1, user_input2, user_input3|

Sketchup.active_model.entities.clear!

width = user_input1.to_f

length = user_input2.to_f

depth = user_input3.to_f

model = Sketchup.active_model

entities = model.active_entities

UI.messagebox(nm)

pts = []

pts[0] = [0, 0, 0]

pts[1] = [width, 0, 0]

pts[2] = [width, length, 0]

pts[3] = [0, length, 0]

# Add the face to the entities in the model

face = entities.add_face(pts)

face.reverse! unless face.normal.samedirection?(Z_AXIS)

face.pushpull depth

require 'fileutils'

FileUtils.mkdir_p("C:/MySketchupDialog/#{nm}")

box_Info = [

{ Name: nm , Width: width, Length: length , Depth: depth }

]

require 'csv'

CSV.open("C:/MySketchupDialog/#{nm}/testMyCsv.csv", "w") do |csv|

csv << ["Name", "Width", "Length", "depth"]

box_Info.each do |bx|

csv << [bx[:Name], bx[:Width], bx[:Length], bx[:Depth]]

end

end

}

javescript has this:

function sendDataToSketchUp() {
  var nm = document.getElementById('nam');
  var user_input1 = document.getElementById('id1');
  var user_input2 = document.getElementById('id2');
  var user_input3 = document.getElementById('id3');
  alert("name: " + nm.value + " width " + user_input1.value + " Length: " + user_input2.value + " height: " + user_input3.value);
  sketchup.getUserInput(nm.value, user_input1.value, user_input2.value, user_input3.value)

}

The alert does come up with the correct results.

The console does error when I click the button, saying “getUserInput” is not a function, I assume it’s because I haven’t called drawBox.rb yet.