概要
windows11に、sketchup6を入れてみた。
rubyやってみた。
練習問題
UI testを書け。
写真
サンプルコード
require 'sketchup.rb'
def beepTest
status = UI.beep
if (status)
UI.messagebox status
else
UI.messagebox status
end
end
def inputBoxTest
prompts = ["Width", "Height", "Depth"]
values = [6, 5, 4]
results = inputbox prompts, values, "Test"
end
def getMenuTest
draw_menu = UI.menu("Draw")
if (draw_menu)
UI.messagebox "Success"
else
UI.messagebox "Failure"
end
begin
invalid_menu = UI.menu("InvalidMenu")
rescue
UI.messagebox $!.message
end
end
def messageBoxTest
keypress = UI.messagebox "Testing with Just a String"
UI.messagebox keypress
UI.messagebox "Testing with a String and Type", MB_MULTILINE
UI.messagebox "Testing with a String, Type, and Title", MB_MULTILINE, "Test"
keypress = UI.messagebox "Testing MB_OKCANCEL", MB_OKCANCEL
UI.messagebox keypress
keypress = UI.messagebox "Testing MB_YESNOCANCEL", MB_YESNOCANCEL
UI.messagebox keypress
UI.messagebox "Testing MB_YESNO", MB_YESNO
keypress = UI.messagebox "Testing MB_RETRYCANCEL", MB_RETRYCANCEL
UI.messagebox keypress
keypress = UI.messagebox "Testing MB_ABORTRETRYIGNORE", MB_ABORTRETRYIGNORE
UI.messagebox keypress
end
def openURLTest
status = UI.openURL("http://www.sketchup.com")
if (status)
UI.messagebox status
else
UI.messagebox "Failure"
end
end
def openPanelTest
begin
status = UI.openpanel "Select image file", "", "*.jpg"
rescue
UI.messagebox $!.message
end
end
def savePanelTest
status = UI.savepanel
if (status)
UI.messagebox status
else
UI.messagebox "Failure"
end
end
def playSoundTest
begin
pSound = UI.play_sound "mediadiscussion.wav"
rescue
UI.messagebox $!.message
end
end
def startTimerTest
id = UI.start_timer(10) {UI.beep}
if (id)
UI.messagebox id
else
UI.messagebox "Failure"
end
end
def stopTimerTest
id = UI.start_timer(10) {UI.beep}
if (id)
UI.messagebox id
else
UI.messagebox "Failure"
end
UI.stop_timer id
UI.messagebox "Stopped"
end
def toolbarUITest
toolbar = UI::Toolbar.new "Test"
toolbar = UI.toolbar "Test"
if (toolbar)
UI.messagebox toolbar
else
UI.messagebox "Failure"
end
end
def uitest
puts "beepTest"
puts "inputBoxTest"
puts "getMenuTest"
puts "messageBoxTest"
puts "openURLTest"
puts "openPanelTest"
puts "savePanelTest"
puts "playSoundTest"
puts "startTimerTest"
puts "stopTimerTest"
puts "toolbarUITest"
end
以上。