Skip to content

Instantly share code, notes, and snippets.

@sam75782008
Last active May 16, 2017 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam75782008/be81b79eba47d2eb9dabdffbac93ddd9 to your computer and use it in GitHub Desktop.
Save sam75782008/be81b79eba47d2eb9dabdffbac93ddd9 to your computer and use it in GitHub Desktop.
# WebDialog Test
face_wd = UI::WebDialog.new "Face Maker"
face_wd.set_size 600, 350
path = Sketchup.find_support_file "Html_try.html", "Plugins"
face_wd.set_file path
# callback from html
face_wd.add_action_callback("create_face") {|d, arg|
if arg.to_s.length ==0
puts "Coordinate must be effective."
else
v = arg.to_s.split(",")
pt1 = Geom::Point3d.new(Float(v[0].strip), Float(v[1].strip),
Float(v[2].strip))
pt2 = Geom::Point3d.new(Float(v[3].strip), Float(v[4].strip),
Float(v[5].strip))
pt3 = Geom::Point3d.new(Float(v[6].strip), Float(v[7].strip),
Float(v[8].strip))
pt4 = Geom::Point3d.new(Float(v[9].strip), Float(v[10].strip),
Float(v[11].strip))
#Sketchup.active_model.entities.add_face pt1, pt2, pt3, pt4
Sketchup.active_model.entities.add_face pt1, pt2, pt3, pt4
end
}
if RUBY_PLATFORM.index "darwin"
face_wd.show_modal
else
face_wd.show
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment