概要
windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
練習問題やってみた。
練習問題
webdialogで、rubyコンソールを書け。
写真
サンプルコード
def testweb1
wd = UI::WebDialog.new("Ruby ", true, 'Console', 500, 200)
wd.set_html <<-EOS
<html>
<head>
</head>
<body>
<textarea id="out" cols=60 rows=5></textarea>
<br>
<input type="text" id="src" size="58" value="alert" ><a href="skp:run">run</a>
</body>
</html>
EOS
wd.add_action_callback('run') do |d, a|
command = wd.get_element_value('src')
puts command
res = command + " => "
begin
result = eval(command)
res += result.inspect.inspect
rescue Exception => e
res += e.message.inspect
res += e.backtrace.inspect.inspect
end
wd.execute_script("document.getElementById('out').value ='#{res}';")
end
wd.show
end
以上。